Is it possible to constrain the lsp to one file only?

I have multiple test files currently in a folder and would like to rename the functions within them to merge them into one file. Each file has a main function and their own function routine functions. I would like to rename these function with lsp with the name of the file appended to the front my current lua implementation is.

local ts_utils = require("nvim-treesitter.ts_utils")

local function mysplit(inputstr, sep)
	if sep == nil then
		sep = "%s"
	end
	local t = {}
	for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do
		table.insert(t, str)
	end
	return t
end

local lang = "c"
local buf_nr = vim.api.nvim_get_current_buf()
local l_tree = vim.treesitter.get_parser(buf_nr, lang)
local syntax_t = l_tree:parse()
local root = syntax_t[1]:root()

local query = vim.treesitter.parse_query(
	lang,
	[[
  (function_declarator
   declarator: (identifier)@annotation
  )
]]
)

for _, captures, metadata in query:iter_matches(root, buf_nr) do
	local filename = vim.api.nvim_buf_get_name(buf_nr)
	local splitted = mysplit(filename, "/")
	filename = mysplit(splitted[#splitted], ".")
	local n_name = filename[1] .. vim.treesitter.query.get_node_text(captures[1], buf_nr)
	ts_utils.goto_node(captures[1])
	vim.lsp.buf.rename(new_name)
end

However the lsp rename finds the main functions of the other files and renames them as well, which is undesired behaviour. is it possible to constrain the lsp rename to one file only?