1 of 92

Vim + Clojure

Tatsuhiro Ujihisa @ VimConf2015

2015-11-21 Tokyo, Japan

2 of 92

Expected types of audiences

  • Vim users
  • Clojure users

3 of 92

Expected types of audiences

  • Vim users
  • Clojure users not necessary
  • Vim plugin authors
  • Vim plugin users
  • Programmers

Difficulty: ★☆☆ (Easy)

4 of 92

Vim + Clojure

Tatsuhiro Ujihisa @ VimConf2015

2015-11-21 Tokyo, Japan

5 of 92

Clojure

A programming language

6 of 92

Clojure

  • S-Expression
  • Immutability / Concurrency
  • Awesome designing
  • JVM / JavaScript

7 of 92

Clojure

  • S-Expression
  • Immutability / Concurrency
  • Awesome designing
  • JVM / JavaScript

8 of 92

Challenges

  • S-Expression
  • Speed (bootup)
  • Complexity

9 of 92

Vim plugins

For Clojure

10 of 92

Vim plugins

  • paredit
  • slimv
  • sexp
  • VimClojure
  • clojure-static
  • ft-clojure
  • fireplace
  • neoclojure

11 of 92

paredit.vim

http://www.vim.org/scripts/script.php?script_id=3998

12 of 92

Maintain the balanced state of matched chars.

Similar to paredit.el for Emacs

13 of 92

y}

14 of 92

dd

15 of 92

Pros: at almost every moment ()s match

Parenthesis as first citizens

16 of 92

Cons (½):

  • They sometimes don’t
  • Some limited actions�(eg. undo)

Vim’s features as second-class citizens

17 of 92

Cons (2/2):

  • Hard to remap

Vim’s features as second-class citizens

18 of 92

Last update:

2 years ago

19 of 92

slimv.vim

20 of 92

IDE for Lisps

Contains

  • Paredit
  • REPL with SWANK (see the next slide)
  • Doc lookup

21 of 92

SWANK

A TCP server / Common Lisp, Clojure, or Scheme

Evaluating, Compiling, Debugging, or Profiling

Backend for SLIME

22 of 92

Last update:

5 days ago

23 of 92

sexp

24 of 92

<Plug>(sexp.*)

25 of 92

Last update:

9 months ago

26 of 92

Vim plugins

  • ☑paredit
  • ☑slimv
  • ☑sexp
  •  VimClojure
  •  clojure-static
  •  ft-clojure
  •  fireplace
  •  neoclojure

27 of 92

-

28 of 92

Tatsuhiro Ujihisa

@ujm

http://github.com/ujihisa

29 of 92

Scala at Hootsuite

PHP, Scala, Bash

Ansible, ZeroMQ, RabbitMQ, Kafka, MySQL, MongoDB, Memcached, Consul, etc

30 of 92

Software Developer

Not Software Engineer

It’s illegal in British Columbia, Canada

31 of 92

Travelling Japan w/ JRP

2015-11-14 to 2015-11-24

Vancouver->Tokyo->Hakata->Nagasaki->Shimonoseki->Kokura->Hiroshima->�Kure->Hiroshima->Osaka->Kyoto->Nara->Kyoto->Nagoya->Tokyo->Vancouver

32 of 92

Minecraft

Since 2010

Bukkit, Spigot

Clojure, JRuby, Scala, Rhino, Groovy

33 of 92

Civilization 5

Since 2013

1438hrs

http://www.nicovideo.jp/user/2809370

34 of 92

35 of 92

36 of 92

37 of 92

Zenbook + Gentoo + Vim

MacBook Pro + OSX + Vim

Tried IntelliJ

38 of 92

-

39 of 92

Vim + Clojure

Tatsuhiro Ujihisa @ VimConf2015

2015-11-21 Tokyo, Japan

40 of 92

VimClojure

http://www.vim.org/scripts/script.php?script_id=2501

41 of 92

“filetype, syntax, indent plugin’’

i.e. everything

42 of 92

(no parenthesis match editing something)

Use with paredit, slimv, or sexp.

43 of 92

optional: SLIME like interface

REPL, doc lookup, omni completion(!), evaluation from buffer

44 of 92

Last update:

3 years ago

45 of 92

clojure-static

https://github.com/guns/vim-clojure-static

46 of 92

indent / syntax

It also contains ftplugin to set some options, but not for key mappings.

47 of 92

autoload/clojurecomplete.vim

Predefined keywords.

...why not syntax complete or dictionary complete…?

48 of 92

Comes with Vim

Try `locate clojurecomplete` on your computer

49 of 92

Extracted from VimClojure

50 of 92

Last update:

5 months ago

51 of 92

ft-clojure

https://github.com/thinca/vim-ft-clojure

52 of 92

thinca

53 of 92

syntax / indent

syntax/clojure.vim

autoload/clojure/syntax.vim

54 of 92

Rainbow

55 of 92

Vim plugins

  • ☑paredit
  • ☑slimv
  • ☑sexp
  • ☑VimClojure
  • ☑clojure-static
  • ☑ft-clojure
  •  fireplace
  •  neoclojure

56 of 92

fireplace

https://github.com/tpope/vim-fireplace

57 of 92

Tim Pope

58 of 92

REPL + many

backend: cider-nrepl

59 of 92

nrepl

A Clojure Network REPL

The new standard

`lein repl` or use from Clojure programs

60 of 92

if_python

or

python as external command

61 of 92

Inconsistent commands/functions

62 of 92

Inconsistent commands/functions

:Source :Doc

:FindDoc :Connect

no ftplugin dir

63 of 92

completion

fireplace#omnicomplete

Automatic

64 of 92

Last update:

7 days ago

65 of 92

neoclojure

https://github.com/ujihisa/neoclojure.vim

66 of 92

completion

quickrun

ref

unite-outline

67 of 92

ujm

68 of 92

No REPL

quickrun is what you want.

69 of 92

No state

Why do we human still have to manage connections to the active Clojure processes?

70 of 92

quickrun

runner/neoclojure

Persistent process, managed by neoclojure,

using vital’s ConcurrentProcess module

71 of 92

You can kill the process at any time

ConcurrentProcess manages the internal state.

It’ll run slow when there’s no existing process,

but it won’t block Vim

72 of 92

Completions

Java class names `java.lang.String`

Static methods `(String/format)`

based on `(ns (:import …))`

73 of 92

Synchronous completion

neoclojure#complete#omni

It blocks Vim, but always available

74 of 92

Asynchronous completion

omnifunc=neoclojure#complete#omni_auto

It runs only when it’s already available immediately, but�it’s guaranteed not to block Vim

75 of 92

“Simplicity”

Clojure’s philosophy

Avoid incidental complexity, but�admit essential complexity

76 of 92

No network connection

Just use STDIN/STDOUT

Assume Clojure processes belong to a Vim,�not many-to-many

77 of 92

78 of 92

vim-ref

unite-outline

Only if you already have them

79 of 92

Last update:

0 days ago

80 of 92

-

81 of 92

Vim plugins

  • ☑paredit
  • ☑slimv
  • ☑sexp
  • ☑VimClojure
  • ☑clojure-static
  • ☑ft-clojure
  • fireplace
  • neoclojure

82 of 92

Vim plugins that I’m actively using

  • ☑paredit
  • ☑slimv
  • ☑sexp
  • ☑VimClojure
  • ☑clojure-static
  • ☑ft-clojure
  • fireplace
  • neoclojure

83 of 92

-

84 of 92

How to I code Clojure usually

85 of 92

  • Write some code, following leiningen standard dir structure (src/aaa/bbb.clj)
  • <Space>r to run quickrun runner/neoclojure
  • For scratching create an anonymous buffer and quickrun
  • neocomplete auto-completion
  • K to lookup doc
  • Sometimes unite-process to kill the running process�or call neoclojure#killall()

86 of 92

Vim + Clojure

Tatsuhiro Ujihisa @ VimConf2015

2015-11-21 Tokyo, Japan

http://twitter.com/ujm

http://github.com/ujihisa

87 of 92

-

88 of 92

(FAQ) What’s the name of the programming langugage for Vim?

“Vim script”

not VimL nor VimScript

They are just typos

89 of 92

(FAQ) vim-sexp key mappings

90 of 92

(FAQ) what do you think about the Vim plugin names that contain objective adjectives such as simple or easy?

oh…

Don’t use them without clarifying what they really mean.

Simple implementation for yourself or for people who makes plugins for that? Easy to start using or easy to debug problems?

91 of 92

(FAQ) Where can I find your Civ5 play videos?

92 of 92

(FAQ) Where can I join your Minecraft server?

Ask me at Lingr Vim room

http://lingr.com/room/vim