

Vim+Tmux配置Scheme编程环境
source link: https://blackdragonf.github.io/2017/12/11/Vim-Tmux%E9%85%8D%E7%BD%AEScheme%E7%BC%96%E7%A8%8B%E7%8E%AF%E5%A2%83/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Vim+Tmux配置Scheme编程环境
12月 11, 2017 发布在 环境配置
最近开始阅读Structure of Interpretation of Computer Science即计算机程序的构造与解释这本书。该书中使用的是Scheme作为Lisp的方言。
在此之前华盛顿大学的《程序设计语言》这门课的PartB中,我使用的Lisp方言是Racket,配合DrRacket作为IDE使用。因为最近一直在配置vim,这一次打算使用vim作为主力开发环境。
如果你对我的配置文件(vim,tmux等)感兴趣,可以看这里。
最终的效果如下图所示:

最初的思路来自于网上的一篇文章,作者也是正在阅读SICP这本书,其提到了使用tmux进行分屏,在一边使用vim进行代码的编辑,另一边运行mit-scheme作为REPL(Read-Eval-Print-Loop)解释scheme代码。
但是如果这么做的话,需要反复执行mit-scheme < source.scm
,这样做显然不能提高我们编程的效率。
这几天逛友链博客的时候发现刚好Kyler也在读SICP并且配置了vim环境,具体可以参考这篇博客。
受到这篇博客的启发,我决定使用vim-slime来“沟通”vim和tmux,将vim中的Scheme代码发送到运行在tmux中的解释器,并且运行给出结果。
在学习tmux的过程中我接触到了tmuxinator这个tmux配置管理工具。可以通过tmuxinator直接配置tmux session,十分方便。
这篇博客的配置依赖于:
- vim(文本编辑器)
- tmux和tmuxinator(终端会话工具)
- mit-scheme(Scheme解释器)
首先在家目录下的.tmuxinator子文件夹下创建新的配置文件scheme.yml:
# tmuxinator configuration file for scheme
# location: ~/.tmuxinator/scheme.yml
name: scheme
root: .
startup_window: main
socket_name: tmux_scheme
windows:
- main:
layout: even-horizontal
panes:
- vim <%= @args[0] %>
- mit-scheme
该配置文件指定新的scheme session拥有一个窗口main,该窗口有两个窗格,一个执行vim,另一个执行mit-scheme,并且创建的session的socket name为tmux_scheme。
然后我们在.vimrc中安装并配置vim-slime插件。
这里我直接使用插件管理器Vundle安装vim-slime:
Bundle 'jpalardy/vim-slime'
然后在.vimrc中加入配置:
" vim-slime configuration
" 设置目标为tmux
let g:slime_target = "tmux"
" 为tmux设置默认配置,指定socket_name为tmux_scheme,目标窗格为当前窗口的第2个窗格
let g:slime_default_config = {"socket_name": "tmux_scheme", "target_pane":":.1"}
" 指定slime在第一次发送代码时不要询问配置
let g:slime_dont_ask_default = 1
" 指定作为缓冲区的文件(该文件默认在执行完后不会被清空或者删除)
let g:slime_paste_file = "$HOME/.slime_paste"
vim-slime的默认快捷键是(两次Ctrl-C)发送代码; v(Ctrl-C + v)修改配置。
最后编写测试文件test.scm,执行tmuxinator start scheme test.scm
,在vim中按下两次Ctrl-C。应该能实现和上文效果图一样的效果。
本篇博客只是给出了大概的环境配置的思路以及一些具体的配置文件。
如果想要深度地定制属于自己的Scheme开发环境,你可能还需要阅读vim、vim-slime、tmux、tmuxinator的文档与网上的教程。
配置的方式也不仅仅局限于tmux,gnu-screen、vim-terminal等同样能作为vim-slime连接的目标。
配置的环境也不必仅仅局限于Scheme,python、sml等解释型语言均可使用。
Recommend
-
9
Scheme 编程环境的设置 介绍了这么久的 Scheme,却没有讲过如何配置一个高效的 Scheme 的编程环境。有些人开始学习 Scheme 的时候感觉无从下手...
-
23
安装Powerline并配置Vim、Bash、tmux、IPython、pdb 2020-09-21 21:59:17 +08 字数:1546 标签: Bash
-
22
Table of Contents有一些 vim 主题(如 gruvbox 或 solarized8)在 GUI 和终端下效果不同,有可能是因为这个主题需要 true color (2...
-
30
Tmux and Vim: Copy and Paste on macOS Sierra Posted: 2017-03-22 - Last updated: 2019-06-05 Tagged
-
9
vim+tmux 真彩色256color配置 vim是我们最喜爱的编辑器,tmux是我们最喜爱的终端管理器,它们的搭配可以让你的工作效率提升到难以想象的高度。默认情况下,linux的终端是8位的彩色配置,也就说它的颜色过于单一,然而其实大部分情况下它都是支持...
-
15
Learn Linux, Vim, Git, Tmux, Gpg and more
-
10
1. Shell概论Shell是一个用C语言编写的程序,它诞生于Unix,是我们通过命令行与Unix/Linux交互的工具。笼统地说:Shell既是一种命令语言,又是一种程序设计语言。 而Shell脚本是一种为Shell编写的脚本程序,有的时候也被称为Shel...
-
29
Introduction If you write code in multiple languages you may have found it tiresome to maintain an IDE for each. After some experimentation I found the combination of Vim and Tmux to be the ideal solution for my case. T...
-
11
Vim, tmux, and Fish 2023-01-18 @ 11:23 I do most of my text editing with
-
10
256 colors in putty, tmux/screen and vim · GitHub Instantly share code, notes, and snippets. 256 colors in putty, tmux/scr...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK