Skip to content

Commit 2065f4e

Browse files
aspeddroryyppy
andauthored
vim-rescript v3: Remove server and vim commands (#72)
* init v3 * polish * remove examples * update readme.md * update readme.md * update readme.md * Update doc/rescript.txt Co-authored-by: Patrick Ecker <[email protected]> * Update README.md Co-authored-by: Patrick Ecker <[email protected]> * Update CHANGELOG.md Co-authored-by: Patrick Ecker <[email protected]> * Update CHANGELOG.md Co-authored-by: Patrick Ecker <[email protected]> * update CHANGELOG.md * update Makefile * update CONTRIBUTING.md * update gitignore * more updates * Update README.md Co-authored-by: Patrick Ecker <[email protected]> --------- Co-authored-by: Patrick Ecker <[email protected]>
1 parent 7690aa0 commit 2065f4e

File tree

248 files changed

+60
-29656
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

248 files changed

+60
-29656
lines changed

.github/workflows/pull-request.yml

+2-10
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,7 @@ jobs:
1010
with:
1111
neovim: true
1212
- uses: actions/checkout@v1
13-
- uses: actions/setup-node@v1
14-
with:
15-
node-version: '12.x'
16-
registry-url: 'https://registry.npmjs.org'
17-
- run: npm install
18-
- name: Test with neovim
19-
run: |
20-
nvim --version
21-
vim --version
22-
make test
13+
- name: Neovim Version
14+
run: nvim --version
2315
- name: Test syntax
2416
run: make test-syntax

.gitignore

-22
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,4 @@
2424
.merlin
2525
.DS_Store
2626

27-
.bsb.lock
28-
lib/bs
29-
node_modules
30-
test/**/*.js
3127
doc/tags
32-
33-
server/**/*.d.ts
34-
server/**/*.js.map
35-
server/node_modules/.bin
36-
37-
# We don't need that file
38-
server/analysis_binaries/README.md
39-
40-
# We need to vendor node_modules and all the executables
41-
!server/**/node_modules/
42-
!server/analysis_binaries/darwin/rescript-editor-analysis.exe
43-
!server/analysis_binaries/linux/rescript-editor-analysis.exe
44-
!server/analysis_binaries/win32/rescript-editor-analysis.exe
45-
46-
examples/**/node_modules
47-
examples/**/lib
48-
examples/**/src/*.js
49-
examples/**/.merlin

CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@
22

33
## master
44

5+
**Breaking Changes:**
6+
7+
- Remove vendored ReScript LS and remove native Vim Commands (e.g. `:RescriptBuild`, etc)
8+
- The ReScript Language Server will now be shipped as a dedicated npm package [rescript-language-server](https://github.com/rescript-lang/rescript-vscode/tree/master/server#rescript-language-server)
9+
- Migrate to the official language server as described in our README instructions
10+
511
**Improvements:**
612

7-
- Improve syntax highlighting for escaped backticks in interpolated strings ([#55](https://github.com/rescript-lang/vim-rescript/pull/55))
13+
- Improve syntax highlighting for escaped backticks in interpolated strings ([#55](https://github.com/rescript-lang/vim-rescript/pull/55))
814
- Highlight improvements ([#69](https://github.com/rescript-lang/vim-rescript/pull/69))
915

1016
## 2.1.0

CONTRIBUTING.md

+1-72
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
## Development
44

55
- Clone the repo
6-
- `npm install` dependencies
7-
- `make test` to run the tests
8-
- `make test-syntax`, require Neovim >= 0.9.0
6+
- `make test-syntax` to run the syntax tests, require Neovim >= 0.9.0
97

108
**Working within VIM**
119

@@ -19,9 +17,6 @@ Plug ~/Projects/vim-rescript
1917
- Run `:PlugInstall` (you'll not see the plugin in the interactive vim-plug list, because it is a local project)
2018
- You can open and edit functionality in any plugin file. After any changes, just run `:so %` in the same buffer to source the current file, then proceed to do your manual tests
2119

22-
**Integration Specs:**
23-
For all the informal specs about editor integration & the ReScript platform, check out the [CONTRIBUTING](https://github.com/rescript-lang/rescript-vscode/blob/master/CONTRIBUTING.md) file of the rescript-vscode reference implementation.
24-
2520
### Syntax Tests
2621

2722
Syntax tests require Neovim >= 0.9.0
@@ -35,69 +30,3 @@ Syntax tests require Neovim >= 0.9.0
3530
//^
3631
```
3732
- Run `make test-syntax`
38-
39-
### Use custom rescript-editor-support.exe
40-
41-
> Note: Don't do this as a ReScript user. This is only intended for extension development purposes only.
42-
> We won't consider bug reports that are caused by custom editor-support setups.
43-
44-
We are currently using a forked version of RLS to be able to do type-hinting (without using an LSP client actually). To build the binary, do the following:
45-
46-
```bash
47-
cd ~/Projects
48-
49-
git clone https://github.com/rescript-lang/rescript-editor-support.git
50-
51-
# You will need esy to build the project
52-
esy
53-
```
54-
55-
After a successful build, you will find a binary at path `_esy/default/build/install/default/bin/Bin`. To make things easier, we will symlink it:
56-
57-
```bash
58-
cd ~/Projects/rescript-editor-support
59-
ln -s _esy/default/build/install/default/bin/Bin bin.exe
60-
```
61-
62-
Now open your `vimrc` file and add following line:
63-
64-
```vim
65-
let g:rescript_editor_support_exe = "~/Projects/reason-language-server/bin.exe"
66-
```
67-
68-
#### Testing the local setup
69-
70-
That's it! Now you should be able to use `RescriptTypeHint` / omnicompletion on a `.res` file:
71-
72-
- Within a ReScript project, create a new `myfile.res`
73-
- Add `let a = ""`
74-
- Move your cursor above the empty string `""`
75-
- Type `:RescriptTypeHint`. A preview window will open to show the type information
76-
77-
78-
79-
## Vendoring a new rescript-vscode version
80-
81-
We are currently vendoring rescript-vscode to provide all the binaries + LSP for our coc-vim setup.
82-
83-
First, `curl` the tagged zip bundle from the `rescript-vscode` GH releases:
84-
85-
```
86-
curl -L https://github.com/rescript-lang/rescript-vscode/releases/download/1.1.1/rescript-vscode-1.1.1.vsix -o rescript-vscode-1.1.1.zip
87-
```
88-
89-
Unzip it and replace the `rescript-vscode` directory. Like this:
90-
91-
```
92-
unzip rescript-vscode-1.1.1.zip -d rescript-vscode-1.1.1
93-
rm -rf server
94-
95-
mv rescript-vscode-1.1.1/extension/server server
96-
```
97-
98-
Lastly:
99-
100-
- Check in the changes and push to a working branch
101-
- Do a last sanity check, update your `PlugInstall` to point to the newly created branch. Run `PlugUpdate` and check if the LSP / vim setup works as expected
102-
- Run `:RescriptInfo` and check if the output reflects all the changes
103-
- To wrap up, merge the branch, update CHANGELOG, push a new tag

Makefile

-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
.PHONY: test test-ci
2-
3-
MYVIM ?= nvim --headless
4-
5-
INMAKE := 1
6-
export INMAKE
7-
8-
test:
9-
@$(MYVIM) -u ./test/test_all.vim
10-
111
test-syntax:
122
nvim -l test/test-syntax.lua
133
git diff --name-only --exit-code -- 'test/syntax/expected/*.res.txt'

README.md

+39-85
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,22 @@
11
# vim-rescript
22

3-
**This is the official vim plugin for ReScript.**
3+
Vim runtime files for ReScript.
44

55
> If you are experiencing any troubles, open an issue or visit our [Forum](https://forum.rescript-lang.org) and ask for guidance.
66
77
## Features
88

9-
**Supported Workflows:**
10-
- Plain VIM (without any third party plugins)
11-
- LSP + [coc-vim](https://github.com/neoclide/coc.nvim)
12-
13-
**Basics:**
149
- Syntax highlighting for ReSript files
1510
- Filetype detection for `.res`, `.resi`
1611
- Basic automatic indentation
17-
- Includes LSP for coc-vim usage
18-
- Proper tooling detection for monorepo like setups (yarn workspaces)
19-
20-
**Provided by vim-rescript commands:**
21-
- Formatting `.res` files w/ syntax error diagnostics in VIM quickfix
22-
- Convert existing `.re` /`.rei` files to `.res` /`.resi`
23-
- Type hint for current cursor position
24-
- Jump to definition for current cursor position
25-
- Building the current projec w/ build diagnostics in VIM quickfix
26-
- Autocompletion w/ Vim's omnicomplete
27-
28-
**Monorepo support:**
29-
30-
The vim-rescript plugin automatically updates its project environment on each file open separately.
31-
- Tested for yarn workspaces (see [./examples/monorepo-yarn-workspaces])
32-
- **Note for non-LSP usage:** Always make sure to switch to a `.res` file **within the project you want to compile** before running `:RescriptBuild` etc.
3312

3413
See `:h rescript` for the detailed [helpfile](./doc/rescript.txt).
3514

36-
## Requirements
37-
38-
The plugin works with projects based on `[email protected]` or later
39-
4015
## Installation
4116

4217
`vim-rescript` can be installed either manually or by using your favourite plugin manager.
4318

44-
```viml
19+
```vim
4520
" vim-plug
4621
Plug 'rescript-lang/vim-rescript'
4722
@@ -50,89 +25,68 @@ Plugin 'rescript-lang/vim-rescript'
5025
5126
" NeoBundle
5227
NeoBundle 'rescript-lang/vim-rescript'
28+
```
5329

54-
" Packer
55-
use 'rescript-lang/vim-rescript'
30+
```lua
31+
-- Lazy.nvim
32+
{ 'rescript-lang/vim-rescript', ft="rescript" }
5633
```
5734

5835
You can also pin your installation to specific tags (check our releases [here](https://github.com/rescript-lang/vim-rescript/releases)):
5936

60-
```
37+
With Plug:
38+
39+
```vim
6140
Plug 'rescript-lang/vim-rescript', {'tag': 'v2.1.0'}
6241
```
6342

64-
## Using vim-rescript with COC
65-
66-
(`:h rescript-coc`)
67-
68-
Our plugin comes with all the necessary tools (LSP + editor-support binaries for Windows, Mac, Linux) to set up coc-vim.
69-
After the installation, open your coc config (`:CocConfig`) and add the following configuration:
43+
With [Lazy.nvim](https://github.com/folke/lazy.nvim):
7044

71-
```json
72-
"languageserver": {
73-
"rescript": {
74-
"enable": true,
75-
"module": "~/.config/nvim/plugged/vim-rescript/server/out/server.js",
76-
"args": ["--node-ipc"],
77-
"filetypes": ["rescript"],
78-
"rootPatterns": ["bsconfig.json"]
79-
}
80-
}
45+
```lua
46+
{ 'rescript-lang/vim-rescript', tag = "v2.1.0" }
8147
```
8248

83-
- The config above assumes that you were using `vim-plug` for plugin installations.
84-
- Adapt your `module` path according to the install location of your vim-rescript plugin.
85-
- Save the configuration, run `:CocRestart` and open a (built) ReScript project and check your code for type-hints.
86-
87-
**Note:** Even if you are using COC, we recommend checking out the builtin commands that come with `vim-rescript` (`:h rescript-commands).
88-
89-
## Using vim-rescript's functionality (no vim-coc, no vim-ale, etc)
49+
## Setup LSP
9050

91-
(`:h rescript-config`)
51+
First you need install the language server for ReScript from npm
9252

93-
Vim comes with a set of useful functions that are completely self contained and work with any neovim setup without any plugins:
53+
> **Note**
54+
> If you are using [mason.nvim](https://github.com/williamboman/mason.nvim) you can install the ReScript Language Server using the command `MasonInstall rescript-language-server`
9455
56+
```sh
57+
npm install -g @rescript/language-server
9558
```
96-
:h :RescriptFormat
97-
:h :RescriptUpgradeFromReason
98-
:h :RescriptBuild
99-
:h :RescriptTypeHint
100-
:h :RescriptJumpToDefinition
101-
:h :RescriptInfo
102-
```
103-
Please refer to the [doc](./doc/rescript.txt) file for more details!
10459

105-
We don't come with any predefined keybindings, but provide a basic set of keymappings down below.
60+
The binary is called `rescript-language-server`
10661

107-
### Basic Key Bindings
62+
### Neovim LSP builtin
10863

109-
These bindings won't collide with any other mappings in your vimrc setup, since they are scoped to `rescript` buffers only:
64+
Install the [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) package and setup the LSP
11065

111-
```vim
112-
" Note that <buffer> allows us to use different commands with the same keybindings depending
113-
" on the filetype. This is useful if to override your e.g. ALE bindings while working on
114-
" ReScript projects.
115-
autocmd FileType rescript nnoremap <silent> <buffer> <localleader>r :RescriptFormat<CR>
116-
autocmd FileType rescript nnoremap <silent> <buffer> <localleader>t :RescriptTypeHint<CR>
117-
autocmd FileType rescript nnoremap <silent> <buffer> <localleader>b :RescriptBuild<CR>
118-
autocmd FileType rescript nnoremap <silent> <buffer> gd :RescriptJumpToDefinition<CR>
119-
```
66+
```lua
67+
local lspconfig = require('lspconfig')
12068

121-
### Configure omnicomplete Support
69+
lspconfig.rescriptls.setup{}
70+
```
12271

123-
(`:h rescript-omnicomplete`)
72+
For more details, see [server configuration](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rescriptls)
12473

125-
We support auto-completion with Vim's builtin `omnifunc`, which is triggered with `C-x C-o` in insert mode to look for autocomplete candidates.
74+
### COC (Vim or Neovim)
12675

127-
> While omnicomplete's dialog is open, use `C-n` / `C-p` to navigate to the next / previous item
76+
(`:h rescript-coc`)
12877

129-
```vim
130-
" Hooking up the ReScript autocomplete function
131-
set omnifunc=rescript#Complete
78+
After the installation, open your coc config (`:CocConfig`) and add the following configuration:
13279

133-
" When preview is enabled, omnicomplete will display additional
134-
" information for a selected item
135-
set completeopt+=preview
80+
```json
81+
"languageserver": {
82+
"rescript": {
83+
"enable": true,
84+
"module": "rescript-language-server",
85+
"args": ["--node-ipc"],
86+
"filetypes": ["rescript"],
87+
"rootPatterns": ["rescript.json", "bsconfig.json"]
88+
}
89+
}
13690
```
13791

13892
## Credits

0 commit comments

Comments
 (0)