-
-
Notifications
You must be signed in to change notification settings - Fork 15
vim-rescript v3: Remove server
and vim commands
#72
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
Merged
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6e2ff84
init v3
aspeddro f8b925f
polish
aspeddro 2405e87
remove examples
aspeddro a3e487b
update readme.md
aspeddro 97fc7d4
update readme.md
aspeddro d69b7fe
update readme.md
aspeddro 813ed23
Update doc/rescript.txt
aspeddro 0750c11
Update README.md
aspeddro 823e9a4
Update CHANGELOG.md
aspeddro e081c00
Update CHANGELOG.md
aspeddro c851808
update CHANGELOG.md
aspeddro c7d0ee1
update Makefile
aspeddro bf1454e
update CONTRIBUTING.md
aspeddro b9728ff
update gitignore
aspeddro 6585fd0
more updates
aspeddro 06c6785
Update README.md
aspeddro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,3 @@ | ||
.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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 `[email protected]` 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' | ||
|
||
|
@@ -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 `MasonInstall rescript-language-server` | ||
|
||
```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 | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.