Skip to content

Commit

Permalink
Installation notes in README
Browse files Browse the repository at this point in the history
Neovim native LSP example

Add editor setup notes to README
  • Loading branch information
nodreb-borrus committed Mar 25, 2022
1 parent 9d68d94 commit 46e84f3
Showing 1 changed file with 112 additions and 12 deletions.
124 changes: 112 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,129 @@ Install with:
npm install -g @urbit/hoon-language-server
```

Make sure you have a fake ~zod running on localhost:8080 and you've installed a
Hoon plugin for your editor, like hoon.vim.
This installs `hoon-language-server` which allows your code editor to communicate with an urbit ship running locally on your development machine.

To use with nvim-lspconfig:
The default options are: `-p 80 -d 0 -u http://localhost -s zod -c lidlut-tabwed-pillex-ridrup`

Add a snippet to init.vim:
- `-p` is the port your ship is accessible on over HTTP
- `-d` is the delay for running didSave events
- `-u` is the URL of your ship
- `-s` is the `@p` of your ship (without a sig)
- `-c` is the `+code` of the running urbit (also without a sig)

## Urbit Setup

You must have a fake ship running and it must be running the hoon language server. To create and start a fake `~zod`:

```
urbit -F zod -c zod
```

In the urbit dojo, start the language server:

```
|start %language-server
```

If you need the passcode for your ship, enter this in dojo:

```
+code
```

To start the same ship again in the future just run:

```
urbit zod
```

in the same directory you created it in.

## Editor Setup

Your code editor now needs to use `hoon-language-server` as an LSP provider. There are plugins for common editors that add syntax highlighting, etc. and help connect to the language server.

### VSCode

* [hoon-vscode](https://github.com/famousj/hoon-vscode)
* [hoon-assist-vscode](https://github.com/urbit/hoon-assist-vscode)

### Emacs

* [hoon-mode.el](https://github.com/urbit/hoon-mode.el)

### Vim

* [hoon.vim](https://github.com/urbit/hoon.vim)

`hoon.vim` does not use the language server itself, but the github page describes a setup using `vim-lsp`.

### Neovim

Neovim users should use [hoon.vim](https://github.com/urbit/hoon.vim) with one of the following LSP setups:

#### Native LSP

Install [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) to simplify your local configuration. To use the [default configuration](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.txt#hoon_ls), add the following to `init.lua`:

```
require'lspconfig'.hoon_ls.setup{}
```

To modify the default options use:

```
lua << EOF
require'lspconfig'.hoon_ls.setup{
cmd = {"hoon-language-server" "-p", "80", "-d", "500", -s "zod", "-u", "http://localhost", "-c" "lidlut-tabwed-pillex-ridrup"},
filetypes = {"hoon"},
single_file_support = true
}
```

You can include lua snippets in your `init.vim` like so:

```
lua << EOF
require'lspconfig'.hoon_ls.setup{}
EOF
```

Note that the values provided above are for reference, you can choose to provide no flags/values and use the defaults or set your own.
Alternatively, configure native LSP manually without additional plugins:

The default values are: `-p 80 -d 0 -u http://localhost -s zod -c lidlut-tabwed-pillex-ridrup`
```
-- Only `configs` must be required, util is optional if you are using the root resolver functions, which is usually the case.
local configs = require ('lspconfig.configs')
local util = require ('lspconfig.util')
- `-p` is the port your ship is accessible on over HTTP
- `-d` is the delay for running didSave events
- `-u` is the URL of your ship
- `-s` is the `@p`` of your ship (without a sig)
- `-c` is the `+code` of the running urbit (also without a sig)
configs['hoon_ls'] = {
default_config = {
cmd = { 'hoon-language-server', "-p", "8080" },
filetypes = { 'hoon' },
single_file_support = true,
root_dir = function(fname)
return util.find_git_ancestor() or vim.loop.os_homedir()
end,
},
docs = {
description = [[
https://github.com/urbit/hoon-language-server
]],
},
}
```

#### coc.nvim

Install and configure [coc.nvim](https://github.com/neoclide/coc.nvim), then add a `languageserver` entry to `~/.config/nvim/coc-settings.json`:

```
{
"languageserver": {
"hoon-language-server": {
"command": "hoon-language-server",
"args": ["-p", "8080"],
"filetypes": ["hoon"]
}
}
}
```

0 comments on commit 46e84f3

Please sign in to comment.