Compare commits

...

2 commits

Author SHA1 Message Date
e5f2e1beb0 overlays: remove 'nvim-treesitter-legacy-shim'
All checks were successful
ci/woodpecker/push/check Pipeline was successful
With the migration complete, I do not need it anymore.

This reverts commit bf260de243.
2026-01-21 11:43:02 +00:00
80c2c4dd55 WIP: home: vim: migrate to new 'nvim-treesitter'
WIP: highlighting isn't working, it looks like none of the grammars are
detected...
2026-01-21 11:43:02 +00:00
3 changed files with 58 additions and 32 deletions

View file

@ -60,8 +60,8 @@ in
nvim-lspconfig # Easy LSP configuration
lsp-format-nvim # Simplified formatting configuration
none-ls-nvim # LSP integration for linters and formatters
nvim-treesitter-legacy.withAllGrammars # Better highlighting
nvim-treesitter-textobjects-legacy # More textobjects
nvim-treesitter.withAllGrammars # Better highlighting
nvim-treesitter-textobjects # More textobjects
plenary-nvim # 'null-ls', 'telescope' dependency
# Completion

View file

@ -1,4 +1,4 @@
local ts_config = require("nvim-treesitter.configs")
local treesitter = require("nvim-treesitter")
local ts_select = require("nvim-treesitter-textobjects.select")
local ts_move = require("nvim-treesitter-textobjects.move")
local utils = require("ambroisie.utils")
@ -52,17 +52,6 @@ local moves = {
{ "[]", goto_previous_end("@class.outer"), desc = "Previous class end" },
}
ts_config.setup({
highlight = {
enable = true,
-- Avoid duplicate highlighting
additional_vim_regex_highlighting = false,
},
indent = {
enable = true,
},
})
require("nvim-treesitter-textobjects").setup({
select = {
-- Jump to matching text objects
@ -73,3 +62,58 @@ require("nvim-treesitter-textobjects").setup({
set_jumps = true,
},
})
-- Automatically setup treesitter for supported filetypes
local function treesitter_try_attach(buf, language)
-- Try to load language
-- NOTE: the best way I found to check if a filetype has a grammar
if not vim.treesitter.language.add(language) then
return false
end
-- Syntax highlighting
vim.treesitter.start(buf, language)
-- Indentation
vim.bo.indentexpr = "v:lua.require('nvim-treesitter').indentexpr()"
return true
end
vim.api.nvim_create_autocmd("FileType", {
pattern = "*",
group = vim.api.nvim_create_augroup("treesitter_attach", { clear = true }),
callback = function(args)
local buf, filetype = args.buf, args.match
local language = vim.treesitter.language.get_lang(filetype)
if not language then
return
end
treesitter_try_attach(buf, language)
end,
})
-- FIXME: is this more correct?
--[[
local installable_parsers = require("nvim-treesitter").get_available()
vim.api.nvim_create_autocmd("FileType", {
pattern = "*",
group = vim.api.nvim_create_augroup("treesitter_attach", { clear = true }),
callback = function(args)
local buf, filetype = args.buf, args.match
local language = vim.treesitter.language.get_lang(filetype)
if not language then
return
end
if not treesitter_try_attach(buf, language) then
if vim.tbl_contains(installable_parsers, language) then
-- Not already installed, so try to install them via nvim-treesitter if possible
require("nvim-treesitter").install(language):await(function()
treesitter_try_attach(buf, language)
end)
end
end
end,
})
--]]

View file

@ -1,18 +0,0 @@
final: prev:
let
inherit (final) lib;
overrides = final: prev:
let
hasLegacyPackage = prev ? nvim-treesitter-legacy;
in
{
nvim-treesitter-textobjects-legacy = prev.nvim-treesitter-textobjects.overrideAttrs {
dependencies = [ final.nvim-treesitter-legacy ];
};
} // (lib.optionalAttrs (!hasLegacyPackage) {
nvim-treesitter-legacy = final.nvim-treesitter;
});
in
{
vimPlugins = prev.vimPlugins.extend (overrides);
}