Skip to content
mads kjeldgaard edited this page Mar 27, 2022 · 2 revisions

Fuzzy searching SuperCollider stuff

There's an entire plugin dedicated to fuzzy searching SuperCollider using this plugin.

Read on if you want to do things yourself...

Searching the Ctags

If you install either fzf.vim or skim.vim, it is possible to use the CTags produced by SCNvim to do a fuzzy search on the class system by simply running :Tags or :Tags! (the latter is a full screen version of the former)

Fuzzy search help files

It's also possible to fuzzy search the help files generated by SCNvim. This is a feature included in the supercollider-h4x-nvim plugin, but here it is using a bit lua code that you may put in your configs and then call from within vim:

function fzf(sources, sinkfunc, custom_options)
	local cmd = "fzf" -- Replace with skim if that's what you are using
	local fzf_run = vim.fn[cmd .. "#run"]
	local fzf_wrap = vim.fn[cmd .. "#wrap"]

	local wrapped = fzf_wrap("test", {
		source = sources,
		options = custom_options or {},
		-- don't set `sink` or `sink*` here
	})

	wrapped["sink*"] = nil   -- this line is required if you want to use `sink` only
	wrapped.sink = sinkfunc
	fzf_run(wrapped)
end

-- Get help tags as table
function scnvim_unpack_tags_table()
	local root = vim.g.scnvim_root_dir
	local classes = root .. "/scnvim-data/tags"
	local tagsfile = io.open(classes)
	local help = {}

	for line in tagsfile:lines() do
		local tagname, tagpath, _, _= line:match("%s*(.-)\t%s*(.-)\t%s*(.-)\t%s*(.-)")
		help[tostring(tagname)] = tagpath
		-- print(tagname)
	end

	return help
end

-- Call this function to fuzzy search help files
function scnvim_fuzzy_help()
	local help = scnvim_unpack_tags_table()
	local help_keys = {};

	for k,_ in pairs(help) do
		table.insert(help_keys, tostring(k))
	end

	fzf(help_keys, function(class_name)
		vim.fn["scnvim#help#open_help_for"](tostring(class_name))
	end)
end