-
Notifications
You must be signed in to change notification settings - Fork 28
Tips and tricks
Various tips and tricks for scnvim!
Many tips are presented in autocmd
fashion so you can just copy and paste them to your init.vim
. If you don't want to use autocmd
for configuration look here instead.
Use an augroup
to avoid autocmd
build up.
Example augroup
" NOTE: the augroup called scnvim is reserved by the plugin
augroup scnvim_settings
autocmd FileType supercollider setlocal ...
augroup END
Indendation
autocmd FileType supercollider setlocal tabstop=4 softtabstop=4 shiftwidth=4
Wrap the post window output
autocmd FileType scnvim setlocal wrap
First get the location of your config directory.
:echo stdpath('config')
In your shell, cd
to that directory and create after/ftplugin/supercollider.vim
then add settings using setlocal
.
Map any piece of SuperCollider code to a key
autocmd FileType supercollider nnoremap <silent><buffer> <F2> :call scnvim#sclang#send('100.rand')<CR>
Map any piece of SuperCollider code to a key (silent version)
autocmd FileType supercollider nnoremap <silent><buffer> <F3> :call scnvim#sclang#send_silent('100.rand')<CR>
Custom mapping for block evaluation
autocmd FileType supercollider nmap <Space> <Plug>(scnvim-send-block)
local scnvim = require'scnvim'
-- Get the help source URI for "subject"
-- @param subject The subject to find
-- @param cb A callback which gets the URI as its first argument
local function get_help_uri(subject, cb)
local cmd = [[SCDoc.helpSourceDir +/+ \"Classes\" +/+ \"%s\" ++ \".schelp\"]]
cmd = string.format(cmd, subject)
scnvim.eval(cmd, cb)
end
-- Open the help source file for the word under the cursor
return function()
local subject = vim.fn.expand('<cword>')
get_help_uri(subject, function(result)
result = string.format('edit %s', result)
vim.cmd(result)
end)
end
Then map a key sequence to execute the exported lua function
nnoremap <F5> <cmd>lua require'path.to.file'()<cr>
If you put the code snippet directly in your init.vim you will not be able to require it in the mapping as in the example above. You would need to put the (exported) function in global scope instead and simply call it.