Skip to content

Commit

Permalink
feat: various features + prepare for alpha release
Browse files Browse the repository at this point in the history
  • Loading branch information
tommasongr committed May 6, 2021
1 parent 2858fef commit 2f66a0f
Show file tree
Hide file tree
Showing 18 changed files with 523 additions and 238 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
main.dist.js
main.dist.js
.DS_Store
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Version 0.5 - Alpha

### FEATURES

- Added Rails project detection
- Added Rails Server Task
- Added Rails About sidebar
- Added Rails Documentation search
- Added Rails list and last migration commands
- Added Rails alternate file command
- Added Erb Tag Switcher
- Added Status Notifications
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Tommaso Negri

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Ruby on Rails for Nova editor - ALPHA

This extension is still in Alpha and various features will be added later on. If you have any suggestion or you have some free time you are free to contribute.

## Features

### Rails Server Task

Automatically generate a Task for running the Rails Server command.

### Search in various documentations

Run the Search Documentation command for searching in different documentations online.

### Open the last migration or list them all

Run the Last Migration or the List Migrations commands for streamlining those operations.

### Open Alternate File

Run the Open Alternate File for rapidly switching between tests and model/controller/etc files.

### ERB Tag Switcher

Quickly switch between `<%`, `<%=` & `<%#` with a single shortcut.

Select a text to wrap it in ERB tags or just use `⌘-shift->` to create a tag and start typing the expression.

## Features on their way

- Solargraph support
- Solargrah settings exposed
- Scaffolding Solargraph Files for better Rails Support

## Contributors

You are welcome to contribute in any way you can think of!

Thanks to @devjah, @jonathanpike and @Wylan for their work on different extensions which have been integrated in this suite.
3 changes: 3 additions & 0 deletions Rails.novaextension/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
CHANGELOG.md
README.md
LICENSE
.DS_Store
13 changes: 11 additions & 2 deletions Rails.novaextension/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## Version 1.0
## Version 0.5 - Alpha

Initial release
### FEATURES

- Added Rails project detection
- Added Rails Server Task
- Added Rails About sidebar
- Added Rails Documentation search
- Added Rails list and last migration commands
- Added Rails alternate file command
- Added Erb Tag Switcher
- Added Status Notifications
39 changes: 39 additions & 0 deletions Rails.novaextension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Ruby on Rails for Nova editor - ALPHA

This extension is still in Alpha and various features will be added later on. If you have any suggestion or you have some free time you are free to contribute.

## Features

### Rails Server Task

Automatically generate a Task for running the Rails Server command.

### Search in various documentations

Run the Search Documentation command for searching in different documentations online.

### Open the last migration or list them all

Run the Last Migration or the List Migrations commands for streamlining those operations.

### Open Alternate File

Run the Open Alternate File for rapidly switching between tests and model/controller/etc files.

### ERB Tag Switcher

Quickly switch between `<%`, `<%=` & `<%#` with a single shortcut.

Select a text to wrap it in ERB tags or just use `⌘-shift->` to create a tag and start typing the expression.

## Features on their way

- Solargraph support
- Solargrah settings exposed
- Scaffolding Solargraph Files for better Rails Support

## Contributors

You are welcome to contribute in any way you can think of!

Thanks to @devjah, @jonathanpike and @Wylan for their work on different extensions which have been integrated in this suite.
3 changes: 3 additions & 0 deletions Rails.novaextension/Tests/ruby.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
chars = 'a,b,c'

chars.split(',').length
59 changes: 29 additions & 30 deletions Rails.novaextension/extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Ruby on Rails",
"organization": "Tommaso Negri",
"description": "Ruby on Rails and Ruby support for Nova editor.",
"version": "0.1",
"version": "0.5",
"main": "main.dist.js",
"license": "MIT",
"keywords": [
Expand All @@ -12,7 +12,6 @@
"nova",
"syntax",
"ruby on rails",
"solargraph",
"migrations",
"documentation"
],
Expand All @@ -21,7 +20,6 @@
"funding": "https://www.paypal.com/paypalme/tommasonegri/15EUR",
"bugs": "https://github.com/tommasongr/nova-rails/issues",
"categories": [
"languages",
"clips",
"commands",
"completions",
Expand Down Expand Up @@ -83,8 +81,8 @@
],
"editor": [
{
"title": "Rails ERB Tag Switcher",
"command": "tommasonegri.rails.erb.tagSwitcher",
"title": "ERB Tag Switcher",
"command": "tommasonegri.rails.commands.erb.tagSwitcher",
"shortcut": "cmd-shift->",
"when": "editorHasFocus",
"filters": {
Expand Down Expand Up @@ -130,35 +128,36 @@
],
"config": [
{
"title": "General",
"description": "VLS (Vue Language Server) is a language server implementation compatible with Language Server Protocol. It is developed as part of the Vetur project.",
"type": "section",
"children": [
{
"key": "tommasonegri.rails.config.general.task.railsServerProvider",
"title": "Provide Task for Rails Server",
"description": "Include completion for module export and auto import them.",
"type": "boolean",
"default": true
}
]
"key": "tommasonegri.rails.config.general.task.railsServerProvider",
"title": "Provide Task for Rails Server",
"description": "Generate a Task for starting the Rails Server.",
"type": "boolean",
"default": true
},
{
"key": "tommasonegri.rails.config.general.statusNotifications",
"title": "Status Notifications",
"description": "Show a notification when the server changes status. For example on realod, stop and start. If disabled you will only be notified on crashes or errors.",
"type": "boolean",
"default": true
}
],
"configWorkspace": [
{
"title": "General",
"description": "VLS (Vue Language Server) is a language server implementation compatible with Language Server Protocol. It is developed as part of the Vetur project.",
"type": "section",
"children": [
{
"key": "tommasonegri.rails.config.general.task.railsServerProvider",
"title": "Provide Task for Rails Server",
"description": "Include completion for module export and auto import them.",
"type": "enum",
"values": ["Global Default", "Enable", "Disable"],
"default": "Global Default"
}
]
"key": "tommasonegri.rails.config.general.task.railsServerProvider",
"title": "Provide Task for Rails Server",
"description": "Generate a Task for starting the Rails Server.",
"type": "enum",
"values": ["Global Default", "Enable", "Disable"],
"default": "Global Default"
},
{
"key": "tommasonegri.rails.config.general.statusNotifications",
"title": "Status Notifications",
"description": "Show a notification when the server changes status. For example on realod, stop and start. If disabled you will only be notified on crashes or errors.",
"type": "enum",
"values": ["Global Default", "Enable", "Disable"],
"default": "Global Default"
}
]
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "nova-rails",
"version": "0.1.0",
"description": "Rails support for Nova Editor.",
"version": "0.5.0",
"description": "Ruby on Rails and Ruby support for Nova editor.",
"main": "src/Scripts/main.js",
"scripts": {
"build": "npx rollup -c",
"build": "npx rollup -c && cp CHANGELOG.md README.md LICENSE Rails.novaextension",
"watch": "onchange -i \"src/**/*.js\" \"src/**/*.json\" -- npm run build",
"publish": "npx rollup -v",
"develop": "rollup -c"
Expand Down
44 changes: 44 additions & 0 deletions src/Scripts/config/general/statusNotifications.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
function reload() {
nova.commands.invoke("tommasonegri.rails.commands.reload");
}

nova.config.onDidChange(
"tommasonegri.rails.config.general.statusNotifications",
reload
);
nova.workspace.config.onDidChange(
"tommasonegri.rails.config.general.statusNotifications",
reload
);

function getExtensionSetting() {
return nova.config.get(
"tommasonegri.rails.config.general.statusNotifications",
"boolean"
);
}

function getWorkspaceSetting() {
const str = nova.workspace.config.get(
"tommasonegri.rails.config.general.statusNotifications",
"string"
);

switch (str) {
case "Global Default":
return null;
case "Enable":
return true;
case "Disable":
return false;
default:
return null;
}
}

export default function statusNotificationsSetting() {
const workspaceConfig = getWorkspaceSetting();
const extensionConfig = getExtensionSetting();

return workspaceConfig === null ? extensionConfig : workspaceConfig;
}
41 changes: 41 additions & 0 deletions src/Scripts/config/solargraph/solargraphHover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
function reload() {
nova.commands.invoke("tommasonegri.rails.commands.reload");
}

nova.config.onDidChange("tommasonegri.rails.config.solargraph.hover", reload);
nova.workspace.config.onDidChange(
"tommasonegri.rails.config.solargraph.hover",
reload
);

function getExtensionSetting() {
return nova.config.get(
"tommasonegri.rails.config.solargraph.hover",
"boolean"
);
}

function getWorkspaceSetting() {
const str = nova.workspace.config.get(
"tommasonegri.rails.config.solargraph.hover",
"string"
);

switch (str) {
case "Global Default":
return null;
case "Enable":
return true;
case "Disable":
return false;
default:
return null;
}
}

export default function solargraphHoverSetting() {
const workspaceConfig = getWorkspaceSetting();
const extensionConfig = getExtensionSetting();

return workspaceConfig === null ? extensionConfig : workspaceConfig;
}
40 changes: 40 additions & 0 deletions src/Scripts/helpers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
import statusNotificationsSetting from "./config/general/statusNotifications";

/**
* @param {string} id Notification ID
* @param {string} title Notification Title
* @param {boolean} showAlways Whether to override the user notifications settings
* @param {string=} body Notification Body
* @param {[string]=} actions Notification Action
* @param {function(any)=} handler Notification Handler
*/
export function showNotification(
id,
title,
showAlways,
body,
actions,
handler
) {
if (showAlways || statusNotificationsSetting()) {
let request = new NotificationRequest(id);

request.title = title;
if (body) {
request.body = body;
}
if (actions) {
request.actions = actions;
}

nova.notifications
.add(request)
.then((reply) => {
if (handler) {
handler(reply);
}
})
.catch((err) => console.error(err, err.stack));
}
}

export function isRailsInProject() {
const gemfilePath = nova.workspace.path + "/Gemfile";

Expand Down
Loading

0 comments on commit 2f66a0f

Please sign in to comment.