Skip to content
This repository was archived by the owner on May 27, 2024. It is now read-only.
This repository was archived by the owner on May 27, 2024. It is now read-only.

[Bug]: highlighting broken after lsp format #49

@raineszm

Description

@raineszm

Neovim version

v0.10.0-dev-510+g3c4890d1e

Language affected

clojure

Query

No response

Strategy

No response

Description

In a clojure file, using the clojure-lsp formatting, the rainbow delimiters become out of sync until the file is edited again.

This can be seen in the below asciicast (which I hopefully formatted correctly).
asciicast

I can reproduce the issue using the following clojure file, deps.edn, and minimal config by opening the file with nvim -u init.lua minimal.clj and running :lua vim.lsp.buf.format()

init.lua

local lazypath = "/tmp/rainbow/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
	vim.fn.system({
		"git",
		"clone",
		"--filter=blob:none",
		"https://github.com/folke/lazy.nvim.git",
		"--branch=stable", -- latest stable release
		lazypath,
	})
end
vim.opt.rtp:prepend(lazypath)
vim.cmd.colorscheme("retrobox")

require("lazy").setup({
	{
		"nvim-treesitter/nvim-treesitter",
		build = ":TSUpdate",
		event = { "BufReadPost", "BufNewFile" },
		opts = {
			ensure_installed = {
				"clojure",
			},
			highlight = {
				enable = true,
			},
			rainbow = {
				enable = true,
			},
		},
		config = function(_, opts)
			if type(opts.ensure_installed) == "table" then
				---@type table<string, boolean>
				local added = {}
				opts.ensure_installed = vim.tbl_filter(function(lang)
					if added[lang] then
						return false
					end
					added[lang] = true
					return true
				end, opts.ensure_installed)
			end
			require("nvim-treesitter.configs").setup(opts)
		end,
	},
	"HiPhish/nvim-ts-rainbow2",
	{
		"neovim/nvim-lspconfig",
		event = { "BufReadPre", "BufNewFile" },
		dependencies = {
			"mason.nvim",
			"williamboman/mason-lspconfig.nvim",
		},
		autoformat = true,
		config = function(_, opts)
			require("lspconfig").clojure_lsp.setup(opts)
		end,
	},
	{
		"williamboman/mason.nvim",
		cmd = "Mason",
		config = true,
	},
	{
		"williamboman/mason-lspconfig.nvim",
		opts = {
			ensure_installed = { "clojure_lsp" },
		},
	},
})

minimal.clj

(defn a-func [x y]
  (let [a 1]
  (let [b 2]
  (+ a b x y))))

(a-func 2 3)

deps.edn

{
 :paths ["."]
 }

It's possible this may be the same bug as this in which case the linked fixes might help?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions