aboutsummaryrefslogtreecommitdiff
path: root/docs/editors/index.html
blob: c80288ba2087d7994032582c7200f3df9bdd92ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<head>
  <link href="../favicon.ico" rel="shortcut icon" type="image/x-icon"/>
  <link href="../style.css" rel="stylesheet"/>
  <title>BQN: Editor support</title>
</head>
<div class="nav">(<a href="https://github.com/mlochbaum/BQN">github</a>) / <a href="../index.html">BQN</a></div>
<h1 id="editor-support"><a class="header" href="#editor-support">Editor support</a></h1>
<style>.Comment,.Function,.Number,.String { color: inherit; }</style>
<p>Editor plugins and other tools for allowing BQN input are in <a href="https://github.com/mlochbaum/BQN/tree/master/editors">this folder</a>. Input always uses the layout shown <a href="https://mlochbaum.github.io/BQN/keymap.html">here</a> (<a href="#alternate-layouts">want another?</a>), and is usually performed with a backslash <code><span class='Value'>\</span></code> prefix, but sometimes with a modifier key such as alt. To type an actual backslash, hit the backslash key twice.</p>
<p>Both the online REPL and the REPLXX build of CBQN (<code><span class='Value'>make</span> <span class='Function'>REPLXX=</span><span class='Number'>1</span></code>) support backslash input with no configuration required.</p>
<p><a href="https://abrudz.github.io/lb/bqn">This bookmarklet</a> enables BQN input in any webpage in your <strong>browser</strong>.</p>
<p><a href="https://gist.github.com/dzaima/35ca0ce12b5e215a62460f00e693984f">This userscript</a> highlights BQN code on <strong>GitHub</strong>. The highlighting library <a href="https://prismjs.com/">prism.js</a> also supports BQN.</p>
<p>For <strong>Android</strong>, <a href="https://github.com/dzaima/hackerskeyboard/releases/latest">this fork</a> adds APL and BQN to Hacker's Keyboard.</p>
<p>For <strong>iPhone</strong>, <a href="https://github.com/gitonthescene/APLKeyboard">this repository</a> includes a BQN keyboard for the Pythonista IDE.</p>
<p>The file <a href="https://github.com/mlochbaum/BQN/blob/master/editors/inputrc">inputrc</a> can be copied or appended to <code><span class='Value'>~</span><span class='Function'>/</span><span class='Value'>.inputrc</span></code> to enable backslash input in <strong>bash</strong>, BQN with <strong>rlwrap</strong>, and other software that uses GNU Readline.</p>
<p>Support for other editors, OSes, or workflows will be gladly accepted!</p>
<h2 id="system-wide"><a class="header" href="#system-wide">System-wide</a></h2>
<h3 id="xkb-unix"><a class="header" href="#xkb-unix">XKB (Unix)</a></h3>
<p>The file <a href="https://github.com/mlochbaum/BQN/blob/master/editors/bqn">bqn</a> is for configuring XKB on Linux, or other systems using X11. It's installed as part of xkeyboard-config 2.36 and later, or can be copied to <code><span class='Function'>/</span><span class='Value'>usr</span><span class='Function'>/</span><span class='Value'>share</span><span class='Function'>/X11/</span><span class='Value'>xkb</span><span class='Function'>/</span><span class='Value'>symbols</span><span class='Function'>/</span></code> for earlier versions. Then run</p>
<pre><span class='Value'>$</span> <span class='Value'>setxkbmap</span> <span class='Function'>-</span><span class='Value'>layout</span> <span class='Value'>us</span><span class='Separator'>,</span><span class='Value'>bqn</span> <span class='Function'>-</span><span class='Value'>option</span> <span class='Value'>grp</span><span class='Head'>:</span><span class='Value'>switch</span>
</pre>
<p>replacing <code><span class='Value'>us</span></code> with your ordinary keyboard layout. <code><span class='Value'>switch</span></code> indicates the right alt key and can be replaced with <code><span class='Value'>lswitch</span></code> for left alt or other codes. The setting will go away on shutdown, so you will probably want to configure it to run every time you start up. The way to do this depends on your desktop environment. For further discussion, see <a href="https://en.wikipedia.org/wiki/X_keyboard_extension">Wikipedia</a> or the <a href="https://aplwiki.com/wiki/Typing_glyphs_on_Linux">APL Wiki</a>.</p>
<p>Another XKB option is to place <a href="https://github.com/mlochbaum/BQN/blob/master/editors/XCompose">XCompose</a> (possibly with adjustments) in <code><span class='Value'>~</span><span class='Function'>/</span><span class='Value'>.</span><span class='Function'>XCompose</span></code> and enable a compose key. This can be done using either OS-specific settings or the following command:</p>
<pre><span class='Value'>$</span> <span class='Value'>setxkbmap</span> <span class='Function'>-</span><span class='Value'>option</span> <span class='Value'>compose</span><span class='Head'>:</span><span class='Value'>rwin</span>
</pre>
<h3 id="windows"><a class="header" href="#windows">Windows</a></h3>
<p>Folder <a href="https://github.com/mlochbaum/BQN/tree/master/editors/autohotkey-win">autohotkey-win</a> contains an <a href="https://en.wikipedia.org/wiki/AutoHotKey">AutoHotKey</a> script and the generated .exe file. It runs as an ordinary program that recognizes BQN key combinations system-wide, using the right alt key (to change this, replace <code><span class='Function'>RAlt</span></code> in the script and rebuild). Move it to the startup folder if you'd like to have it running all the time. You can right-click its icon in the system tray to disable it temporarily.</p>
<p>The <a href="https://github.com/mlochbaum/BQN/blob/master/editors/XCompose">XCompose</a> file, although created for XKB, is also usable with <a href="https://github.com/samhocevar/wincompose">WinCompose</a>.</p>
<h3 id="mac"><a class="header" href="#mac">Mac</a></h3>
<p>There are two keyboard layouts: <a href="https://github.com/mlochbaum/BQN/blob/master/editors/BQN.keylayout">one</a> enables BQN keys with the <code><span class='Function'>Alt</span></code> modifier, and <a href="https://github.com/mlochbaum/BQN/blob/master/editors/BQN_backslash.keylayout">another</a> uses the standard <code><span class='Value'>\</span></code> prefix.</p>
<p>To install:</p>
<ul>
<li>Copy the appropriate <code><span class='Value'>.keylayout</span></code> file to <code><span class='Value'>~</span><span class='Function'>/Library/Keyboard</span> <span class='Function'>Layouts/</span></code>.</li>
<li>Navigate to System Preferences &gt; Keyboard &gt; Input Sources &gt; + &gt; Others &gt; BQN.</li>
<li>Restart, then enable the BQN keyboard with System Preferences &gt; Keyboard &gt; Input Sources &gt; BQN US.</li>
</ul>
<p>Don't use the root-based directory <code><span class='Function'>/Library/Keyboard</span> <span class='Function'>Layouts/</span></code> for the first step, as this will silently fail.</p>
<h2 id="text-editors"><a class="header" href="#text-editors">Text editors</a></h2>
<h3 id="vim"><a class="header" href="#vim">Vim</a></h3>
<p>Copy or symlink all files into the corresponding directories in <code><span class='Value'>~</span><span class='Function'>/</span><span class='Value'>.vim</span></code>. Add the following two lines to <code><span class='Value'>~</span><span class='Function'>/</span><span class='Value'>.vim</span><span class='Function'>/</span><span class='Value'>filetype.vim</span></code>:</p>
<pre>  <span class='Value'>au</span><span class='Function'>!</span> <span class='Function'>BufRead</span><span class='Separator'>,</span><span class='Function'>BufNewFile</span> <span class='Value'>*.bqn</span> <span class='Value'>setf</span> <span class='Value'>bqn</span>
  <span class='Value'>au</span><span class='Function'>!</span> <span class='Function'>BufRead</span><span class='Separator'>,</span><span class='Function'>BufNewFile</span> <span class='Value'>*</span> <span class='Value'>if</span> <span class='Value'>getline</span><span class='Paren'>(</span><span class='Number'>1</span><span class='Paren'>)</span> <span class='Function'>=</span><span class='Value'>~</span> <span class='String'>'</span><span class='Value'>^</span><span class='Comment'>#!.*bqn$' | setf bqn | endif
</span></pre>
<p>Include <code><span class='Value'>syntax</span> <span class='Value'>on</span></code> in your .vimrc for syntax highlighting and <code><span class='Value'>filetype</span> <span class='Value'>plugin</span> <span class='Value'>on</span></code> for keyboard input. View docs from vim with <code><span class='Head'>:</span><span class='Value'>help</span> <span class='Value'>bqn</span></code>.</p>
<p>To use vim-plug to install BQN support for vim, add this to your plugin section of your <code><span class='Value'>.vimrc</span></code>:</p>
<pre>  <span class='Function'>Plug</span> <span class='String'>'</span><span class='Value'>mlochbaum</span><span class='Function'>/BQN</span><span class='String'>'</span><span class='Separator'>,</span> <span class='Brace'>{</span><span class='String'>'</span><span class='Value'>rtp</span><span class='String'>'</span><span class='Head'>:</span> <span class='String'>'</span><span class='Value'>editors</span><span class='Function'>/</span><span class='Value'>vim</span><span class='String'>'</span><span class='Brace'>}</span>
</pre>
<p>Then run <code><span class='Head'>:</span><span class='Function'>PlugInstall</span></code>.</p>
<h4 id="neovim-interactivity"><a class="header" href="#neovim-interactivity">Neovim interactivity</a></h4>
<p>See <a href="https://git.sr.ht/~detegr/nvim-bqn">this repository</a> for an additional plugin that provides bindings to run BQN code as you're editing it.</p>
<h3 id="emacs"><a class="header" href="#emacs">Emacs</a></h3>
<p>Emacs support now lives on <a href="https://github.com/museoa/bqn-mode">museoa/bqn-mode</a>. Clone and add the following two lines to your init file (usually <code><span class='Value'>~</span><span class='Function'>/</span><span class='Value'>.emacs.d</span><span class='Function'>/</span><span class='Value'>init.el</span></code>), replacing the path appropriately.</p>
<pre><span class='Paren'>(</span><span class='Value'>add</span><span class='Function'>-</span><span class='Value'>to</span><span class='Function'>-</span><span class='Value'>list</span> <span class='String'>'</span><span class='Value'>load</span><span class='Function'>-</span><span class='Value'>path</span> <span class='String'>&quot;/path/to/bqn-mode&quot;</span><span class='Paren'>)</span>
<span class='Paren'>(</span><span class='Value'>require</span> <span class='String'>'</span><span class='Value'>bqn</span><span class='Function'>-</span><span class='Value'>mode</span><span class='Paren'>)</span>
</pre>
<h3 id="vs-code"><a class="header" href="#vs-code">VS Code</a></h3>
<p>See <a href="https://github.com/razetime/bqn-vscode">this repository</a>, or install directly through <a href="https://marketplace.visualstudio.com/items?itemName=razetime.bqn-language&ssr=false#overview">Visual Studio Marketplace</a> or <a href="https://open-vsx.org/extension/razetime/bqn-language">Open VSX Registry</a>.</p>
<h3 id="kakoune"><a class="header" href="#kakoune">Kakoune</a></h3>
<p>Copy or symlink <code><span class='Value'>kak</span><span class='Function'>/</span><span class='Value'>autoload</span><span class='Function'>/</span><span class='Value'>filetype</span><span class='Function'>/</span><span class='Value'>bqn.kak</span></code> into <code><span class='Value'>autoload</span><span class='Function'>/</span><span class='Value'>filetype</span></code> in your Kakoune config directory (probably <code><span class='Value'>.config</span><span class='Function'>/</span><span class='Value'>kak</span><span class='Function'>/</span></code>).</p>
<h2 id="alternate-layouts"><a class="header" href="#alternate-layouts">Alternate layouts</a></h2>
<p>All files here use the BQN layout designed for qwerty, which will generally be jumbled in another layout (for example the key for <code><span class='Value'>r</span></code> will still type <code><span class='Function'></span></code>, but it may not be above <code><span class='Value'>c</span></code>, which types <code><span class='Function'></span></code>). The <a href="https://github.com/mlochbaum/BQN/blob/master/editors/remap.bqn">remap.bqn</a> script allows you to remap some files in this repository to a new layout. See <code><span class='Value'>$</span> <span class='Value'>.</span><span class='Function'>/</span><span class='Value'>remap.bqn</span> <span class='Function'>-</span><span class='Value'>h</span></code> for usage. Support for a new layout can be added in the <code><span class='Value'>keys</span></code> array of the script, but do watch for string alignment with the doubled quote character.</p>
<p>(If you haven't installed CBQN but have Node.js, <code><span class='Value'>$</span> <span class='Value'>bqn.js</span> <span class='Value'>editors</span><span class='Function'>/</span><span class='Value'>remap.bqn…</span></code> from the repository root will work too)</p>