Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation notes in README #24

Merged
merged 7 commits into from
Apr 19, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 127 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,132 @@ A language server for Hoon.
Install with:

```
npm install -g hoon-language-server
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.

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

- `-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:

```
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
nodreb-borrus marked this conversation as resolved.
Show resolved Hide resolved
}
```

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

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

Alternatively, configure native LSP manually without additional plugins:

```
-- 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')

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
]],
},
}
```

nodreb-borrus marked this conversation as resolved.
Show resolved Hide resolved
#### 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"]
}
}
}
```