Skip to content

Commit 1480045

Browse files
committed
docs: update editor-setup to match actual implementations
- Neovim/Vim: Use t-ruby-vim plugin with require('t-ruby').setup() - JetBrains: Update settings location to Settings → Tools → T-Ruby - LSP: Use trc --lsp instead of non-existent t-ruby-lsp gem - Sublime/Emacs: Mark as "Coming Soon" with temporary Ruby-mode workaround - Reorder sections: Neovim → Vim → JetBrains → Sublime → Emacs - Add coc.nvim configuration for Neovim - Update LSP capabilities table to reflect actual support status
1 parent baeb5a4 commit 1480045

File tree

3 files changed

+387
-441
lines changed

3 files changed

+387
-441
lines changed

docs/getting-started/editor-setup.md

Lines changed: 129 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -80,229 +80,212 @@ For the best Ruby/T-Ruby experience, also install:
8080

8181
## Neovim
8282

83-
T-Ruby supports Neovim through the built-in LSP client.
83+
T-Ruby provides official Neovim support through the [t-ruby-vim](https://github.com/type-ruby/t-ruby-vim) plugin.
8484

85-
### Using nvim-lspconfig
85+
### Installation
8686

87-
Add to your Neovim configuration:
87+
Using your preferred plugin manager:
8888

89-
```lua title="init.lua"
90-
-- Install t-ruby-lsp if not present
91-
-- gem install t-ruby-lsp
92-
93-
require('lspconfig').t_ruby_lsp.setup {
94-
cmd = { "t-ruby-lsp" },
95-
filetypes = { "truby" },
96-
root_dir = require('lspconfig').util.root_pattern("trbconfig.yml", ".git"),
97-
settings = {
98-
truby = {
99-
typeCheck = {
100-
enabled = true
101-
}
102-
}
103-
}
89+
```lua title="lazy.nvim"
90+
{
91+
'type-ruby/t-ruby-vim',
92+
ft = { 'truby' },
10493
}
10594
```
10695

107-
### Syntax Highlighting with Tree-sitter
108-
109-
For syntax highlighting, add the T-Ruby tree-sitter parser:
110-
111-
```lua title="init.lua"
112-
require('nvim-treesitter.configs').setup {
113-
ensure_installed = { "ruby", "truby" },
114-
highlight = {
115-
enable = true,
116-
},
117-
}
96+
```vim title="vim-plug"
97+
Plug 'type-ruby/t-ruby-vim'
11898
```
11999

120-
### File Type Detection
100+
### LSP Setup
121101

122-
Add file type detection for `.trb` files:
102+
The plugin provides built-in LSP configuration:
123103

124104
```lua title="init.lua"
125-
vim.filetype.add({
126-
extension = {
127-
trb = "truby",
128-
},
129-
})
105+
require('t-ruby').setup()
130106
```
131107

132-
### Recommended Plugins
133-
134-
- **nvim-lspconfig** - LSP configuration
135-
- **nvim-treesitter** - Syntax highlighting
136-
- **nvim-cmp** - Autocompletion
137-
- **lspsaga.nvim** - Enhanced LSP UI
138-
139-
### Complete Neovim Setup Example
108+
Or with custom options:
140109

141110
```lua title="init.lua"
142-
-- File type detection
143-
vim.filetype.add({
144-
extension = {
145-
trb = "truby",
146-
},
147-
})
148-
149-
-- LSP setup
150-
local lspconfig = require('lspconfig')
151-
152-
lspconfig.t_ruby_lsp.setup {
111+
require('t-ruby').setup({
112+
cmd = { 'trc', '--lsp' },
153113
on_attach = function(client, bufnr)
154-
-- Enable completion triggered by <c-x><c-o>
155-
vim.bo[bufnr].omnifunc = 'v:lua.vim.lsp.omnifunc'
156-
157-
-- Keymaps
114+
-- Your on_attach function
158115
local opts = { buffer = bufnr }
159-
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
160116
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
161117
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
162118
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
163-
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, opts)
164-
end,
165-
}
166-
167-
-- Autocompile on save
168-
vim.api.nvim_create_autocmd("BufWritePost", {
169-
pattern = "*.trb",
170-
callback = function()
171-
vim.fn.system("trc " .. vim.fn.expand("%"))
172119
end,
173120
})
174121
```
175122

176-
## Sublime Text
123+
### Commands
177124

178-
### Installing the Package
125+
After setting up LSP, the following commands are available:
179126

180-
1. Install Package Control if you haven't already
181-
2. Open Command Palette (`Cmd+Shift+P` / `Ctrl+Shift+P`)
182-
3. Select "Package Control: Install Package"
183-
4. Search for "T-Ruby" and install
127+
- `:TRubyCompile` - Compile the current file
128+
- `:TRubyDecl` - Generate declaration file
129+
- `:TRubyLspInfo` - Show LSP status
184130

185-
### Manual Installation
131+
### With coc.nvim
186132

187-
Clone the syntax package to your Packages directory:
133+
Add to your `coc-settings.json`:
188134

189-
```bash
190-
cd ~/Library/Application\ Support/Sublime\ Text/Packages/ # macOS
191-
# or
192-
cd ~/.config/sublime-text/Packages/ # Linux
135+
```json
136+
{
137+
"languageserver": {
138+
"t-ruby": {
139+
"command": "trc",
140+
"args": ["--lsp"],
141+
"filetypes": ["truby"],
142+
"rootPatterns": ["trbconfig.yml", ".git/"]
143+
}
144+
}
145+
}
146+
```
147+
148+
### Recommended Plugins
193149

194-
git clone https://github.com/type-ruby/sublime-t-ruby.git T-Ruby
150+
- **nvim-lspconfig** - LSP configuration
151+
- **nvim-cmp** - Autocompletion
152+
- **lspsaga.nvim** - Enhanced LSP UI
153+
154+
## Vim
155+
156+
T-Ruby provides official Vim support through the [t-ruby-vim](https://github.com/type-ruby/t-ruby-vim) plugin.
157+
158+
### Installation
159+
160+
```vim title="vim-plug"
161+
Plug 'type-ruby/t-ruby-vim'
195162
```
196163

197-
### Configuration
164+
Or clone manually:
198165

199-
Add a build system for T-Ruby:
166+
```bash
167+
git clone https://github.com/type-ruby/t-ruby-vim ~/.vim/pack/plugins/start/t-ruby-vim
168+
```
200169

201-
```json title="T-Ruby.sublime-build"
202-
{
203-
"cmd": ["trc", "$file"],
204-
"file_regex": "^(.+):([0-9]+):([0-9]+): (.+)$",
205-
"selector": "source.truby"
206-
}
170+
### Features
171+
172+
- Syntax highlighting for `.trb` and `.d.trb` files
173+
- File type detection
174+
175+
### Custom Key Mappings
176+
177+
```vim title=".vimrc"
178+
autocmd FileType truby nnoremap <buffer> <leader>tc :!trc %<CR>
179+
autocmd FileType truby nnoremap <buffer> <leader>td :!trc --decl %<CR>
207180
```
208181

209182
## JetBrains IDEs (RubyMine, IntelliJ)
210183

184+
T-Ruby provides official JetBrains plugin support through [t-ruby-jetbrains](https://github.com/type-ruby/t-ruby-jetbrains).
185+
211186
### Installing the Plugin
212187

213188
1. Open Settings/Preferences
214189
2. Go to Plugins → Marketplace
215190
3. Search for "T-Ruby"
216191
4. Click Install and restart the IDE
217192

193+
### Features
194+
195+
The plugin provides:
196+
197+
- **Syntax highlighting** for `.trb` and `.d.trb` files
198+
- **Real-time diagnostics** via LSP
199+
- **Autocomplete** with type information
200+
- **Go to definition**
201+
218202
### Configuration
219203

220-
The plugin automatically:
221-
- Associates `.trb` files with T-Ruby
222-
- Provides syntax highlighting
223-
- Shows type errors
204+
The plugin reads project settings from `trbconfig.yml`. Editor-specific settings can be configured in **Settings → Tools → T-Ruby**:
224205

225-
Additional settings in **Settings → Languages & Frameworks → T-Ruby**:
226-
- Enable/disable type checking
227-
- Configure compiler path
228-
- Set output directory
206+
- **trc Path** - Path to the T-Ruby compiler (default: `trc`)
207+
- **Enable LSP** - Enable Language Server Protocol support
208+
- **Enable Diagnostics** - Enable real-time diagnostics
209+
- **Enable Completion** - Enable code completion
210+
211+
:::tip
212+
Like VS Code, compile options should be configured in `trbconfig.yml`, not in IDE settings.
213+
:::
214+
215+
## Sublime Text
216+
217+
:::note[Coming Soon]
218+
Sublime Text support is planned but not yet available. You can use generic syntax highlighting by treating `.trb` files as Ruby.
219+
:::
220+
221+
### Temporary Setup
222+
223+
Add to your Sublime Text settings to use Ruby highlighting:
224+
225+
```json title="Preferences.sublime-settings"
226+
{
227+
"file_associations": {
228+
"*.trb": "Ruby"
229+
}
230+
}
231+
```
229232

230233
## Emacs
231234

232-
### Using t-ruby-mode
235+
:::note[Coming Soon]
236+
Emacs support is planned but not yet available. You can use `ruby-mode` for basic syntax highlighting.
237+
:::
233238

234-
Install via MELPA:
239+
### Temporary Setup
235240

236241
```elisp
237-
(use-package t-ruby-mode
238-
:ensure t
239-
:mode "\\.trb\\'"
240-
:hook (t-ruby-mode . lsp-deferred))
242+
(add-to-list 'auto-mode-alist '("\\.trb\\'" . ruby-mode))
241243
```
242244

243-
### LSP Configuration
244-
245-
Configure lsp-mode for T-Ruby:
245+
For LSP support, configure with the T-Ruby compiler:
246246

247247
```elisp
248248
(use-package lsp-mode
249249
:ensure t
250-
:commands lsp
251250
:config
252-
(add-to-list 'lsp-language-id-configuration '(t-ruby-mode . "truby"))
253251
(lsp-register-client
254252
(make-lsp-client
255-
:new-connection (lsp-stdio-connection '("t-ruby-lsp"))
256-
:major-modes '(t-ruby-mode)
253+
:new-connection (lsp-stdio-connection '("trc" "--lsp"))
254+
:major-modes '(ruby-mode)
257255
:server-id 't-ruby-lsp)))
258256
```
259257

260-
## Vim (without LSP)
261-
262-
For basic Vim support without LSP:
263-
264-
```vim title=".vimrc"
265-
" File type detection
266-
autocmd BufRead,BufNewFile *.trb set filetype=ruby
267-
268-
" Compile on save
269-
autocmd BufWritePost *.trb silent !trc %
270-
271-
" Syntax highlighting (uses Ruby highlighting)
272-
autocmd FileType truby setlocal syntax=ruby
273-
```
274-
275258
## Language Server (LSP)
276259

277-
The T-Ruby Language Server can be used with any LSP-compatible editor.
260+
The T-Ruby compiler includes a built-in Language Server that can be used with any LSP-compatible editor.
278261

279-
### Installation
262+
### Running the LSP Server
280263

281264
```bash
282-
gem install t-ruby-lsp
265+
trc --lsp
283266
```
284267

285-
### Running Manually
286-
287-
```bash
288-
t-ruby-lsp --stdio
289-
```
268+
The LSP server communicates via stdin/stdout in JSON-RPC format.
290269

291270
### Capabilities
292271

293-
The LSP server provides:
294-
295272
| Feature | Support |
296273
|---------|---------|
297-
| Syntax highlighting | Via semantic tokens |
298274
| Error diagnostics | Full |
299275
| Hover information | Full |
300276
| Go to definition | Full |
301-
| Find references | Full |
302277
| Autocomplete | Full |
303-
| Code formatting | Full |
304-
| Code actions | Partial |
305-
| Rename | Full |
278+
| Find references | Planned |
279+
| Code formatting | Planned |
280+
| Rename | Planned |
281+
282+
### Generic LSP Configuration
283+
284+
For editors not listed above, configure your LSP client to run:
285+
286+
```bash
287+
trc --lsp
288+
```
306289

307290
## Troubleshooting
308291

@@ -320,15 +303,14 @@ The LSP server provides:
320303

321304
### LSP not connecting
322305

323-
- Install the LSP: `gem install t-ruby-lsp`
324-
- Check LSP path in editor configuration
325-
- Look at LSP server logs for errors
306+
- Verify `trc` is in your PATH: `which trc`
307+
- Check if LSP mode works: `trc --lsp` (should wait for input)
308+
- Look at editor LSP logs for errors
326309

327310
### Type checking slow
328311

329-
- Disable "check on type" if too slow
330-
- Use "check on save" instead
331-
- Exclude `node_modules` and `vendor` directories
312+
- Use "check on save" instead of real-time checking
313+
- Exclude `vendor` and `node_modules` directories in `trbconfig.yml`
332314

333315
## Next Steps
334316

0 commit comments

Comments
 (0)