• Stars
    star
    101
  • Rank 338,166 (Top 7 %)
  • Language
    Vim Script
  • Created over 8 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🎉 Enjoy writing SML within Vim

vim-better-sml

A complete interactive development environment for Standard ML

vim-better-sml makes working with Standard ML in Vim delightful. Compared the SML support built-in to Vim, vim-better-sml has better syntax highlighting, better indenting, and better interop with external plugins. It also has features that set it apart, like go to definition, get type of idenifier, a built-in REPL, and more.

Here's a quick screencast to show off some of it's best features:

thumbnail


The main features are:

  • Built-in REPL (requires SML/NJ)

    Launch and control an SML/NJ REPL process from Vim. Use it to reload a file, rebuild your with CM.make, and more. Supports creating a new REPL with either Neovim terminal buffers or Vimux tmux panes. When using terminal buffers, the output is syntax highlighted!

  • Type lookup (requires MLton)

    Reveal the type of any variable under your cursor, even those in the Basis Library. This works using MLton's support for def-use files, which are indices of type information about your project.

  • Jump to Definition (requires MLton)

    Reveal the type of any variable under your cursor, even those in the Basis Library. This works using MLton's support for def-use files, which are indices of type information about your project.

  • Automatic Setup

    MLton's def-use files are built in the background for you and kept up to date. You just worry about editing--if something needs to be built, we'll handle building it.

  • Expansive syntax highlighting

    Corrects syntax highlighting in *.sml files, and adds optional concealing (for example, 'a becomes α, and fn becomes λ.).

    Adds syntax highlighting support for many SML-related files types, including *.sig, *.fun, *.cm, *.mlb, *.lex, *.grm, and *.smackspec files.

There are also a whole host of other features to round off sharp edges in Vim's default SML filetype support, including tweaks to how indentation works and setting the 'iskeyword' and 'commentstring' settings. The best part is that it's always improving!

Install

  1. Install this plugin using your preferred plugin manager. For example, to install using vim-plug:

    Plug 'jez/vim-better-sml'

    If you're unfamiliar using Vim plugins, check out Vim as an IDE which will get you up to speed.

  2. Check if you're missing any dependencies:

    vim +SMLCheckHealth
  3. Follow the instructions in the output you see. If you see that all health checks are OK, you're all set!

  4. Otherwise, you might need to install or upgrade some tools on your system. In total, vim-better-sml depends on:

    • For the embedded REPL:
      • Neovim, or Vimux with tmux
      • SML/NJ (brew install smlnj)
    • For language-aware features like type information and go to def:
      • MLton (brew install mlton)
      • (optional) Neovim or Vim 8 for automatically rebuilding indices
    • For showing errors alongside your code:
      • ALE
      • (in fact, vim-better-sml is not required for ALE to show SML errors)

Quickstart

  • To guide you through the setup process:
    • :SMLCheckHealth
  • To ask for the type of a variable:
    • :SMLTypeQuery
  • To jump to a definition:
    • :SMLJumpToDef
  • To open a REPL for the current project:
    • :SMLReplStart
  • To load (or reload) the current file or CM project:
    • :SMLReplBuild
  • To open the current structure into the REPL top-level:
    • :SMLReplOpen
  • To clear the screen on the REPL:
    • :SMLReplClear
  • To set the print depth to 100 (or custom <depth>):
    • :SMLReplPrintDepth [<depth>]

Configuration

Complete usage and configuration can be found in the help:

:help vim-better-sml.

This plugin sets up no keybindings by default. We suggest that you add these settings to your vimrc, but feel free to change them:

augroup vimbettersml
  au!

  " ----- Keybindings -----

  au FileType sml nnoremap <silent> <buffer> <leader>t :SMLTypeQuery<CR>
  au FileType sml nnoremap <silent> <buffer> gd :SMLJumpToDef<CR>

  " open the REPL terminal buffer
  au FileType sml nnoremap <silent> <buffer> <leader>is :SMLReplStart<CR>
  " close the REPL (mnemonic: k -> kill)
  au FileType sml nnoremap <silent> <buffer> <leader>ik :SMLReplStop<CR>
  " build the project (using CM if possible)
  au FileType sml nnoremap <silent> <buffer> <leader>ib :SMLReplBuild<CR>
  " for opening a structure, not a file
  au FileType sml nnoremap <silent> <buffer> <leader>io :SMLReplOpen<CR>
  " use the current file into the REPL (even if using CM)
  au FileType sml nnoremap <silent> <buffer> <leader>iu :SMLReplUse<CR>
  " clear the REPL screen
  au FileType sml nnoremap <silent> <buffer> <leader>ic :SMLReplClear<CR>
  " set the print depth to 100
  au FileType sml nnoremap <silent> <buffer> <leader>ip :SMLReplPrintDepth<CR>

  " ----- Other settings -----

  " Uncomment to try out conceal characters
  "au FileType sml setlocal conceallevel=2

  " Uncomment to try out same-width conceal characters
  "let g:sml_greek_tyvar_show_tick = 1
augroup END

Future Features

None of these are currently in progress. If you're interested in seeing these worked on, let me know!

  • Support Vim 8 terminal buffer for the REPL
  • Make an ALE unused variable linter using def-use information
  • Highlight all uses for a definition
    • Can probably do this with a quickfix window (think: vim-grepper)
  • Refactoring tool
    • Rename variable under cursor, and all uses of that variable
  • Support sending a visual selection to the REPL
  • Refactor most functionality into a standalone language server executable
    • type of ident / go-to-def / etc.
  • Make it easier to get started porting CM to MLBasis
  • Generate a tags file from the def-use files

License

MIT License

More Repositories

1

vim-as-an-ide

Workshop on how to use Vim Plugins.
Vim Script
1,952
star
2

pandoc-starter

📄 My pandoc markdown templates and makefiles
TeX
525
star
3

as-tree

Print a list of paths as a tree of paths 🌳
Rust
454
star
4

tufte-pandoc-css

Starter files for using Pandoc Markdown with Tufte CSS
CSS
311
star
5

git-heatmap

📊 Display a heatmap for oft-edited files
Shell
292
star
6

vim-superman

Read Unix man pages faster than a speeding bullet!
Vim Script
190
star
7

pandoc-markdown-css-theme

CSS files and a template for using Pandoc to generate standalone HTML files
CSS
155
star
8

pandoc-sidenote

Convert Pandoc Markdown-style footnotes into sidenotes
Haskell
136
star
9

dotfiles

My personal collection of configuration files.
Shell
122
star
10

tufte-pandoc-jekyll

A Jekyll theme for using Tufte CSS with Jekyll + Pandoc
SCSS
66
star
11

git-madge

🚀 Git-aware madge wrapper
Shell
65
star
12

hpstr-theme

A Medium-like Octopress theme based on the HPSTR Jekyll theme.
CSS
63
star
13

tunemachine

🎶 A time machine for your Spotify tunes!
CoffeeScript
62
star
14

calz

📆 A natural language alternative to Unix 'cal'
Haskell
59
star
15

bask

😎 Bask in the convenience of a task runner for bash
Shell
58
star
16

vim-github-hub

A Vim filetype plugin for github/hub ⚡
Vim Script
49
star
17

latex-solarized

Provides three LaTeX packages for using the Solarized theme in LaTeX code listings.
TeX
29
star
18

stargaze

⭐ Gaze at repos you've starred
Shell
20
star
19

resume

My resume, written in XeTeX.
TeX
14
star
20

latex-hw-template

LaTeX template useful for formatting homework assignments
TeX
13
star
21

blog

an Octopress blog by Jake Zimmerman
Liquid
13
star
22

cmu-latex-hw-template

A LaTeX template for homework assignments, used widely at CMU.
TeX
12
star
23

pandoc-markdown-jekyll-theme

CSS
10
star
24

viewjrnl

Shell script to group jrnl entries by date and add color.
Shell
7
star
25

bin

My collection of personal scripts. They're not documented and often break. Ask if you have questions.
Shell
7
star
26

talks

💬 Slides and descriptions for talks I've given
TeX
6
star
27

starter-zshrc

You should really consider switching to zsh!
Shell
6
star
28

multi-sub

Substitute a pattern with a replacement on specific lines
OCaml
6
star
29

vim-ispc

Vim syntax highlighting for ISPC.
Vim Script
6
star
30

barchart

📊 Print a bar chart from the command line
Rust
5
star
31

ragel-bison-parser-sandbox

A small parser for the lambda calculus in C++ using Bazel, Ragel, and Bison
C++
5
star
32

cmd-queue

A simple queueing service for CMU students.
CoffeeScript
5
star
33

diff-locs

List the file locations involved in a diff
Haskell
5
star
34

smlnj-viscomp-example

An example of how to use SML/NJ's Visible Compiler APIs
Standard ML
4
star
35

symbol

🔨 A build tool for Standard ML
Shell
4
star
36

stlc-infer

A small interpretter for the simply typed lambda calculus, with type inference
Haskell
4
star
37

multi-grep

Search for a pattern on specific lines
Standard ML
3
star
38

tsim

A Turing machine simulator in SML
Standard ML
3
star
39

rust-lc-interp

Toy interpreter for the lambda calculus to explore Rust
Rust
2
star
40

auditors-webhook

Post commit review using Auditors
CoffeeScript
2
star
41

jez.github.io

A collection of my projects, contact info, and life.
CSS
2
star
42

google-apps-cmu-login

Bare bone demo of how to use Google OAuth2 with Python Social Auth in Django to authenticate by Andrew account.
Python
2
star
43

collate

Command line filter for collating the top and bottom halves of a file
Haskell
1
star
44

awkward-bun

Python
1
star
45

marauder

CSS
1
star
46

spacer

Blank macOS app to take up space
Rust
1
star
47

thoughts

A collection of some essays and longer-form writings.
CSS
1
star
48

flac-post-tag

Generate "post tag system" traces
Haskell
1
star
49

language-communities-on-github

TeX
1
star
50

th-portfolios

Simple app to coordinate uploading and downloading of resumes and profile information at TartanHacks 2014
JavaScript
1
star
51

as-tree-cpp

Print a list of paths as a tree of paths 🌳
Starlark
1
star
52

penndot-dash

A dashboard I designed for one of my class projects
1
star
53

homebrew-formulae

A Homebrew tap for my personal CLI tools
Ruby
1
star
54

JBooks

Java
1
star
55

jquery-lab

Simple game demo in jQuery to demonstrate some principles of frontend development.
JavaScript
1
star
56

vim-sorbet

Vim Script
1
star
57

collate-rs

Rust
1
star