"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Functions """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let s:not_prefixable_keywords = [ "import", "data", "instance", "class", "{-#", "type", "case", "do", "let", "default", "foreign", "--"] " guess correct number of spaces to indent " (tabs are not allowed) function! Get_indent_string() return repeat(" ", 4) endfunction " replace tabs by spaces function! Tab_to_spaces(text) return substitute(a:text, " ", Get_indent_string(), "g") endfunction " Wrap in :{ :} if there's more than one line function! Wrap_if_multi(lines) if len(a:lines) > 1 return [":{"] + a:lines + [":}"] else return a:lines endif endfunction " change string into array of lines function! Lines(text) return split(a:text, "\n") endfunction " change lines back into text function! Unlines(lines) if g:tidal_target == "tmux" " Without this, the user has to manually submit a newline each time " they evaluate an expression with `ctrl e`. return join(a:lines, "\n") . "\n" else return join(a:lines, "\n") endif endfunction " vim slime handler function! _EscapeText_tidal(text) let l:lines = Lines(Tab_to_spaces(a:text)) let l:lines = Wrap_if_multi(l:lines) return Unlines(l:lines) endfunction """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Mappings """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" if !exists("g:tidal_no_mappings") || !g:tidal_no_mappings if !hasmapto('TidalConfig', 'n') nmap c TidalConfig endif if !hasmapto('TidalRegionSend', 'x') xmap s TidalRegionSend xmap TidalRegionSend endif if !hasmapto('TidalLineSend', 'n') nmap s TidalLineSend endif if !hasmapto('TidalParagraphSend', 'n') nmap ss TidalParagraphSend nmap TidalParagraphSend endif imap TidalParagraphSendi nnoremap h :TidalHush nnoremap :TidalHush let i = 1 while i <= 9 execute 'nnoremap '.i.' :TidalSilence '.i.'' execute 'nnoremap :TidalSilence '.i.'' execute 'nnoremap s'.i.' :TidalPlay '.i.'' let i += 1 endwhile endif