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

vim-rescript v3: Remove server and vim commands #72

Merged
merged 16 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
10 changes: 1 addition & 9 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,7 @@ jobs:
with:
neovim: true
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
- run: npm install
- name: Test with neovim
run: |
nvim --version
vim --version
make test
run: nvim --version
- name: Test syntax
run: make test-syntax
17 changes: 0 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,8 @@
.merlin
.DS_Store

.bsb.lock
lib/bs
node_modules
test/**/*.js
doc/tags

server/**/*.d.ts
server/**/*.js.map
server/node_modules/.bin

# We don't need that file
server/analysis_binaries/README.md

# We need to vendor node_modules and all the executables
!server/**/node_modules/
!server/analysis_binaries/darwin/rescript-editor-analysis.exe
!server/analysis_binaries/linux/rescript-editor-analysis.exe
!server/analysis_binaries/win32/rescript-editor-analysis.exe

examples/**/node_modules
examples/**/lib
examples/**/src/*.js
Expand Down
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Changelog

## master
## 3.0.0
aspeddro marked this conversation as resolved.
Show resolved Hide resolved

**Breaking Changes:**

- Remove Server and Vim Commands
aspeddro marked this conversation as resolved.
Show resolved Hide resolved
- 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)
aspeddro marked this conversation as resolved.
Show resolved Hide resolved

**Improvements:**

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

## 2.1.0
Expand Down
8 changes: 0 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
.PHONY: test test-ci

MYVIM ?= nvim --headless

INMAKE := 1
export INMAKE

test:
@$(MYVIM) -u ./test/test_all.vim

test-syntax:
nvim -l test/test-syntax.lua
git diff --name-only --exit-code -- 'test/syntax/expected/*.res.txt'
124 changes: 39 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,22 @@
# vim-rescript

**This is the official vim plugin for ReScript.**
Vim runtime files for ReScript.

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

## Features

**Supported Workflows:**
- Plain VIM (without any third party plugins)
- LSP + [coc-vim](https://github.com/neoclide/coc.nvim)

**Basics:**
- Syntax highlighting for ReSript files
- Filetype detection for `.res`, `.resi`
- Basic automatic indentation
- Includes LSP for coc-vim usage
- Proper tooling detection for monorepo like setups (yarn workspaces)

**Provided by vim-rescript commands:**
- Formatting `.res` files w/ syntax error diagnostics in VIM quickfix
- Convert existing `.re` /`.rei` files to `.res` /`.resi`
- Type hint for current cursor position
- Jump to definition for current cursor position
- Building the current projec w/ build diagnostics in VIM quickfix
- Autocompletion w/ Vim's omnicomplete

**Monorepo support:**

The vim-rescript plugin automatically updates its project environment on each file open separately.
- Tested for yarn workspaces (see [./examples/monorepo-yarn-workspaces])
- **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.

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

## Requirements

The plugin works with projects based on `bs-platform@8.3` or later

## Installation

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

```viml
```vim
" vim-plug
Plug 'rescript-lang/vim-rescript'

Expand All @@ -50,89 +25,68 @@ Plugin 'rescript-lang/vim-rescript'

" NeoBundle
NeoBundle 'rescript-lang/vim-rescript'
```

" Packer
use 'rescript-lang/vim-rescript'
```lua
-- Lazy.nvim
{ 'rescript-lang/vim-rescript' }
aspeddro marked this conversation as resolved.
Show resolved Hide resolved
```

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

```
With Plug:

```vim
Plug 'rescript-lang/vim-rescript', {'tag': 'v2.1.0'}
```

## Using vim-rescript with COC

(`:h rescript-coc`)

Our plugin comes with all the necessary tools (LSP + editor-support binaries for Windows, Mac, Linux) to set up coc-vim.
After the installation, open your coc config (`:CocConfig`) and add the following configuration:
With [Lazy.nvim](https://github.com/folke/lazy.nvim):

```json
"languageserver": {
"rescript": {
"enable": true,
"module": "~/.config/nvim/plugged/vim-rescript/server/out/server.js",
"args": ["--node-ipc"],
"filetypes": ["rescript"],
"rootPatterns": ["bsconfig.json"]
}
}
```lua
{ 'rescript-lang/vim-rescript', tag = "v2.1.0" }
```

- The config above assumes that you were using `vim-plug` for plugin installations.
- Adapt your `module` path according to the install location of your vim-rescript plugin.
- Save the configuration, run `:CocRestart` and open a (built) ReScript project and check your code for type-hints.

**Note:** Even if you are using COC, we recommend checking out the builtin commands that come with `vim-rescript` (`:h rescript-commands).

## Using vim-rescript's functionality (no vim-coc, no vim-ale, etc)
## Setup LSP

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

Vim comes with a set of useful functions that are completely self contained and work with any neovim setup without any plugins:
> **Note**
> If you are using [mason.nvim](https://github.com/williamboman/mason.nvim) you can install the ReScript Language Server using the command `MasonInsall rescript-language-server`
aspeddro marked this conversation as resolved.
Show resolved Hide resolved

```sh
npm install -g @rescript/language-server
```
:h :RescriptFormat
:h :RescriptUpgradeFromReason
:h :RescriptBuild
:h :RescriptTypeHint
:h :RescriptJumpToDefinition
:h :RescriptInfo
```
Please refer to the [doc](./doc/rescript.txt) file for more details!

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

### Basic Key Bindings
### Neovim LSP builtin

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

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

### Configure omnicomplete Support
lspconfig.rescriptls.setup{}
```

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

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.
### COC (Vim or Neovim)

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

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

" When preview is enabled, omnicomplete will display additional
" information for a selected item
set completeopt+=preview
```json
"languageserver": {
"rescript": {
"enable": true,
"module": "rescript-language-server",
"args": ["--node-ipc"],
"filetypes": ["rescript"],
"rootPatterns": ["rescript.json", "bsconfig.json"]
}
}
```

## Credits
Expand Down
Loading