Tremor Language Server (Trill)

WIP server for use with editors and IDEs, when working with tremor's languages. Follows language server protocol.

Features

Diagnostics

tremor-script interpreter errors (as you type or on file save), with hints for fixing (as applicable)

nice-to-have: apply fix suggestions from errors

Completion

code completion (as you type/on-demand) for module functions -- function names with signature/doc info as well as placeholders for arguments.

nice-to-have: code completion for variables as well as other language constructs

Hover

diagnostics and function documentation on mouse hover (or editor command)

nice-to-have: documentation for variables (eg: assignment info)

Navigation

nice-to-have: find all references, symbol search

for later: Go to definiton, peek definition, symbol list (when tremor script has functions)

Refactoring

nice-to-have: rename all references

Quickstart

```sh cd ~/repos git clone git@github.com:wayfair-tremor/tremor-language-server.git cd tremor-language-server

during development

cargo build ln -s target/debug/tremor-language-server ~/bin/ # or anywhere in your $PATH

or install the release build

cargo install --path . --root ~/ # make sure ~/bin/ is in your $PATH ```

VS Code setup

Follow instructions at:

https://github.com/wayfair-tremor/tremor-vscode

Vim setup

Prerequisite: install https://github.com/wayfair-tremor/tremor-vim so that vim is aware of tremor filetypes (you also get syntax highlighting as a bonus).

For use with vim, we have a forked version of ale that can interact with the tremor language server:

https://github.com/anupdhml/ale/tree/tremor

Follow the plugin installation instructions. If you are using vim-plug, this will do:

vim Plug 'anupdhml/ale', { 'branch': 'tremor' }

Vim and ale settings that work nice with the tremor language server:

```vim " completion menu set completeopt=menuone,longest,popup " always show the menu, insert longest match, use popup window for extra info "set completepopup=border:off " remove the border from the completion popup window

" turn on omnicomplete based on ale set omnifunc=ale#completion#OmniFunc

" enable ale completion (as you type), where available "let g:alecompletionenabled = 1

" turn on vim mouse support in all modes (for hover info) set mouse=a

" show hover information on mouse over (vim mouse support should be turned on) " xterm2 makes hover work with tmux as well let g:alesetballoons = 1 set ttymouse=xterm2

" only run linters named in alelinters settings let g:alelinters_explicit = 1

" active linters let g:ale_linters = { \ 'tremor': ['tremor-language-server'], \ 'trickle': ['tremor-language-server'], }

" when to run linting/fixing. choose as desired " " aggressive let g:alefixonsave = 1 let g:alelintontextchanged = 'always' let g:alelintonenter = 1 let g:alelintoninsertleave = 1 " " conservative "let g:alelintontextchanged = 'never' "let g:alelintonenter = 0 "let g:alelintoninsert_leave = 0

" key mappings nmap j (alenextwrap) nmap k (alepreviouswrap) nmap / (alehover) nmap ? (aledetail) nmap ] (alegotodefinition) nmap # (alefind_references) ```

You might want to show ALE counters in your vim status line. If you are using vim lightline:

```vim " for showing linter errrors/warnings. depends on lightline-ale let g:lightline.componentexpand = { \ 'linterchecking': 'lightline#ale#checking', \ 'linterwarnings': 'lightline#ale#warnings', \ 'lintererrors': 'lightline#ale#errors', \ 'linterok': 'lightline#ale#ok', \ } let g:lightline.componenttype = { \ 'linterchecking': 'left', \ 'linterwarnings': 'warning', \ 'lintererrors': 'error', \ 'linterok': 'left', \ } let g:lightline#ale#indicatorchecking = '' let g:lightline#ale#indicatorwarnings = '▲' let g:lightline#ale#indicatorerrors = '✗' let g:lightline#ale#indicatorok = '✓'

" configure lightline components let g:lightline.active = { \ 'left': [ ['mode', 'paste'], \ ['fugitive', 'readonly', 'filename', 'modified'] ], \ 'right': [ [ 'lineinfo' ], \ [ 'percent' ], \ [ 'fileformat', 'fileencoding', 'filetype' ], \ ['linterchecking', 'lintererrors', 'linterwarnings', 'linterok' ] ] \ }

" ale indicators (aligned with indicators used in lightline-ale) " 2 chars to cover the full sign width let g:alesignwarning = '▲▲' let g:alesignerror = '✗✗' ```

For more ale setup and vim configuration:

https://github.com/anupdhml/dotfiles/blob/virtualbox_new/data/.vimrc

If you prefer not to use ale, these vim plugins should also work well as the server client:

Notes

TODO