T-Ruby language support for Vim and Neovim. Provides syntax highlighting and LSP integration for T-Ruby - a TypeScript-style static type system for Ruby.
- Syntax highlighting for
.trband.d.trbfiles - File type detection
- LSP integration for Neovim (via nvim-lspconfig or manual setup)
- coc.nvim support
- T-Ruby Compiler (
trc) must be installed and available in your PATH
gem install t-rubyPlug 'type-ruby/t-ruby-vim'{
'type-ruby/t-ruby-vim',
ft = { 'truby' },
}use {
'type-ruby/t-ruby-vim',
ft = { 'truby' },
}Clone to your Vim/Neovim plugin directory:
# Vim
git clone https://github.com/type-ruby/t-ruby-vim ~/.vim/pack/plugins/start/t-ruby-vim
# Neovim
git clone https://github.com/type-ruby/t-ruby-vim ~/.local/share/nvim/site/pack/plugins/start/t-ruby-vimrequire('t-ruby').setup()Or with custom options:
require('t-ruby').setup({
cmd = { 'trc', '--lsp' },
on_attach = function(client, bufnr)
-- Your on_attach function
end,
})require('t-ruby.lsp').setup_manual({
cmd = { 'trc', '--lsp' },
})Copy the example configuration to your coc-settings.json:
{
"languageserver": {
"t-ruby": {
"command": "trc",
"args": ["--lsp"],
"filetypes": ["truby"],
"rootPatterns": ["trbconfig.yml", ".git/"]
}
}
}After setting up LSP, the following commands are available:
:TRubyCompile- Compile the current file:TRubyDecl- Generate declaration file:TRubyLspInfo- Show LSP status
t-ruby-vim/
├── ftdetect/truby.vim # File type detection
├── ftplugin/truby.vim # File type plugin settings
├── syntax/truby.vim # Syntax highlighting
├── lua/t-ruby/
│ ├── init.lua # Main module
│ └── lsp.lua # LSP configuration
└── coc-settings-example.json
| Plugin Version | T-Ruby Compiler | Vim/Neovim |
|---|---|---|
| 0.1.x | >= 0.0.30 | Vim 8+, Neovim 0.8+ |
- Create a file
hello.trb:
type UserId = String
interface User
id: UserId
name: String
age: Integer
end
def greet(user: User): String
"Hello, #{user.name}!"
end
-
Open in Vim/Neovim - you'll see syntax highlighting
-
For Neovim with LSP: hover over types to see definitions, use
gdto go to definition -
Compile with
:TRubyCompile(Neovim) or:!trc %(Vim)
Add to your ~/.vimrc for customization:
" Custom key mappings
autocmd FileType truby nnoremap <buffer> <leader>tc :!trc %<CR>
autocmd FileType truby nnoremap <buffer> <leader>td :!trc --decl %<CR>
" Custom settings
augroup truby_settings
autocmd!
autocmd FileType truby setlocal shiftwidth=2 softtabstop=2
augroup ENDRecommended key mappings for Neovim:
vim.api.nvim_create_autocmd("FileType", {
pattern = "truby",
callback = function()
local opts = { buffer = true, silent = true }
vim.keymap.set("n", "<leader>tc", ":TRubyCompile<CR>", opts)
vim.keymap.set("n", "<leader>td", ":TRubyDecl<CR>", opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
end,
})- Check filetype:
:set filetype? - Manually set filetype:
:set filetype=truby - Verify syntax file exists:
:echo globpath(&rtp, 'syntax/truby.vim')
- Check if
trcis available::!trc --version - Check LSP status:
:TRubyLspInfo - View LSP logs:
:lua vim.cmd('e ' .. vim.lsp.get_log_path())
Issues and pull requests are welcome! https://github.com/type-ruby/t-ruby-vim/issues
- T-Ruby Compiler - The main T-Ruby compiler
- T-Ruby VS Code - VS Code extension
- T-Ruby JetBrains - JetBrains IDE plugin
MIT