You can install this bundle in TextMate by opening the preferences and going to the bundles tab. After installation it will be automatically updated for you.
- Bundle Styleguide — before you make changes
- Commit Styleguide — before you send a pull request
- Writing Bug Reports — before you report an issue
With the kaffeinated-dev fork of TextMate (2.0.23+kaffeinated.5 or later), Ruby and ERB files in a project with a Gemfile (or gems.rb) get ruby-lsp as their language server:
- Syntax errors and warnings, and RuboCop offenses when the project’s bundle has RuboCop (see below), are shown in the gutter as you type. Click a mark to read it, or press F3 to go to the next one.
- ⎋ completion suggests what ruby-lsp does first, such as the methods and constants of your project and its gems.
- The Language Server bundle has commands that ask ruby-lsp: Complete (⌥⎋, instead of this bundle’s rcodetools completion), Documentation Tooltip (⌃⌥H), Go to Definition (⌃⌘J), Find References (⇧⌃⌘F), Go to Symbol in Project (⌥⌘T), Quick Fix (⌥↩, including Extract Variable and Extract Method for the selection), and Rename Symbol (⌃⌘E).
- In Rails applications, ruby-lsp adds ruby-lsp-rails, which knows the models’ columns, associations, and routes. It starts the application in the background to ask.
ruby-lsp runs in the outermost folder with a Gemfile (so a gem inside an application uses the application’s), with the project’s Ruby through mise when it is installed, otherwise from the PATH in Preferences → Variables. It needs to be installed for each Ruby version: gem install ruby-lsp (with mise, add ruby-lsp to ~/.default-gems to have it installed with new versions). It sets up a bundle of its own in the project’s .ruby-lsp folder, which git ignores, and may run bundle install there.
Set these in Preferences → Variables or a .tm_properties file:
TM_RUBY_LANGUAGE_SERVER: another command to start a language server with, such asbundle exec ruby-lsp.TM_DISABLE_LANGUAGE_SERVER: turns language servers off.
If nothing happens, the server’s messages are in the log: log stream --predicate 'subsystem == "com.macromates.TextMate" && category == "LanguageServer"'.
In projects whose bundle has RuboCop (in the Gemfile, directly or through a gem such as rubocop-rails-omakase), ruby-lsp uses it with the project’s .rubocop.yml:
- Its offenses are shown in the gutter as you type.
- Quick Fix (⌥↩, from the Language Server bundle) corrects the offense on the caret’s line (such as “Autocorrect Style/StringLiterals”), or disables its cop for that line.
- Format Document (⌃⇧H) makes the corrections RuboCop can make safely, as
rubocop --autocorrectdoes. They are made in the document, and can be undone; with TextMate 2.0.23+kaffeinated.8 or later, only the lines that change are replaced, so the caret and bookmarks stay where they are. - Documents are formatted like this when saved (Format on Save), once ruby-lsp has started.
Without ruby-lsp (also while it starts), or in projects whose bundle doesn’t have RuboCop, Format Document runs RuboCop itself: with Bundler when the bundle has it, otherwise the rubocop installed for the project’s Ruby (through mise, when installed). Its changes are made the same way. In Rails views, ⌃⇧H is the Ruby on Rails bundle’s Create Partial From Selection.
Set these in Preferences → Variables or a .tm_properties file:
TM_RUBY_FORMAT_ON_SAVE = false: stops formatting documents when they are saved.TM_RUBOCOP: the command to run RuboCop with, when ruby-lsp doesn’t format, such asbin/rubocop.TM_RUBOCOP_OPTIONS: options added to that command, such as--only Layout.
HTML views (.html.erb, and variants such as .html+phone.erb) are indented with htmlbeautifier when saved (Format ERB on Save). It uses the document’s tab settings, and keeps one blank line between blocks rather than none. It only changes indentation and blank lines. Views with a closing tag that has no opening tag are saved as they are, and a tool tip says where. Only the lines that change are replaced, so with TextMate 2.0.23+kaffeinated.9 or later the caret and bookmarks stay on their lines.
htmlbeautifier is used with Bundler when the project’s bundle has it, otherwise as installed for the project’s Ruby (through mise, when installed). Install it with gem install htmlbeautifier for each Ruby version (with mise, add it to ~/.default-gems). Without it, views are saved as they are.
Set these in Preferences → Variables or a .tm_properties file:
TM_ERB_FORMAT_ON_SAVE = false: stops indenting views when they are saved.TM_HTMLBEAUTIFIER: the command to run htmlbeautifier with.TM_HTMLBEAUTIFIER_OPTIONS: options added to that command, such as--keep-blank-lines 2.
If not otherwise specified (see below), files in this repository fall under the following license:
Permission to copy, use, modify, sell and distribute this
software is granted. This software is provided "as is" without
express or implied warranty, and with no claim as to its
suitability for any purpose.
An exception is made for files in readable text which contain their own license information, or files where an accompanying file exists (in the same directory) with a “-license” suffix added to the base-name name of the original file, and an extension of txt, html, or similar. For example “tidy” is accompanied by “tidy-license.txt”.