From: Brendan Hansen Date: Thu, 23 Nov 2023 15:31:38 +0000 (-0600) Subject: misc updates X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=fafab5ba55b6c34853b3be86d7c5fa17e954bb1b;p=onyxlang.io.git misc updates --- diff --git a/onyx-pkg.ini b/onyx-pkg.ini deleted file mode 100644 index f3352b3..0000000 --- a/onyx-pkg.ini +++ /dev/null @@ -1,24 +0,0 @@ -[metadata] -name=onyxlang-io -description=The onyxlang.io website -url=https://onyxlang.io -author=Brendan Hansen -version=0.0.1 - -[config] -lib_source_directory=./lib -lib_bin_directory=./bin -run_cmd=onyx run build -debug_cmd=onyx run --debug build - -[native_library] - -[dependencies] -git://onyxlang.io/repo/http-server=0.2.23 -git://onyxlang.io/repo/otmp=0.0.25 - -[dependency_folders] -git://onyxlang.io/repo/http-server=http-server -git://onyxlang.io/repo/otmp=otmp -git://onyxlang.io/repo/base64=base64 - diff --git a/onyx-pkg.kdl b/onyx-pkg.kdl new file mode 100644 index 0000000..8ce7dd4 --- /dev/null +++ b/onyx-pkg.kdl @@ -0,0 +1,18 @@ +package { + name "onyxlang-io" + author "Brendan Hansen" + url "https://onyxlang.io" + description "The onyxlang.io website" + version "0.0.1" +} + +config { + dependency_source_path "./lib" + dependency_binary_path "./bin" +} + +dependencies { + http-server "0.2.24" git="git://onyxlang.io/repo/http-server" + otmp "0.0.26" git="git://onyxlang.io/repo/otmp" +} + diff --git a/src/app.onyx b/src/app.onyx index a6bedf4..8734e06 100644 --- a/src/app.onyx +++ b/src/app.onyx @@ -44,7 +44,10 @@ reg: otmp.TemplateRegistry; (req: &Req, res: &Res) => res->render("pages/docs/install", null); @route.{.GET, "/docs/setup"} -(req: &Req, res: &Res) => res->render("pages/docs/setup", null); +(req: &Req, res: &Res) => res->render("pages/docs/env_setup", null); + +@route.{.GET, "/docs/getting_started"} +(req: &Req, res: &Res) => res->render("pages/docs/getting_started", null); Article :: struct { name, description, path, date: str } diff --git a/www/templates/pages/docs.html b/www/templates/pages/docs.html index 1978498..d41c75d 100644 --- a/www/templates/pages/docs.html +++ b/www/templates/pages/docs.html @@ -13,12 +13,12 @@ Onyx Documentation

Getting Started

- Install Onyx locally on your system or use it in your browser. + Install Onyx locally on your system and write your first program.

+ Getting Started Install Environment Setup - Playground

diff --git a/www/templates/pages/docs/env_setup.html b/www/templates/pages/docs/env_setup.html new file mode 100644 index 0000000..0991567 --- /dev/null +++ b/www/templates/pages/docs/env_setup.html @@ -0,0 +1,163 @@ +{{block "title"}}Onyx Environment Setup{{endblock}} + +{{ let navbar_page = "docs" }} + +{{ block "page_content" }} + +
+

Setting Up Your Environment for Onyx

+ +

The following sections will help set up an environment for you to program Onyx effectively.

+ +

+ VS Code + Vim / Neovim + Sublime text + Emacs + Language Server +

+ +

+ (If you don't see your favorite editor here, consider making a issue!) +

+
+ + +
+

Visual Studio Code

+
+
+

+ VS Code Extension +

+ +

+ Onyx has an official published extension on the Visual Studio Marketplace. + Search "Onyx Programming Language" in the extensions panel or install from the marketplace. +

+ +

Alternatively, you can follow these steps to install the extension from the VSIX file included in the Onyx distribution.

+
    +
  1. Hit "Control+Shift+P" on Windows/Linux, or "Command+Shift+P" on MacOS.
  2. +
  3. Search for and select "Extensions: Install from VSIX".
  4. +
  5. Go to your ONYX_PATH and select the .vsix file in the misc folder.

  6. +
  7. Restart VS Code.
  8. +
+ +

This extension does have support for the onyx lsp, assuming that is setup. +

+ +
+

Vim / Neovim

+
+
+

+ Vim Plugin +

+ +

+ Follow the instructions on the onyx.vim GitHub repo. +

+ +

+ Note, that this extension currently does not setup the LSP. + That must be done separately. +

+
+ + +
+

Sublime Text

+
+
+

+ Currently, Onyx does not have a published package on Sublime Text's Package Control, but like VS Code, you are able to install it manually. +

+

+ In the misc folder of your installation, there is a file called onyx.sublime-syntax. Simply copy this into the Packages/User folder for Sublime Text. See more details here. +

+
+ +
+

Emacs

+
+
+

+ Currently, Onyx does not have a published package for Emacs. +

+ +

+ However, in the misc folder, there is an Emacs Lisp file that provides an onyx-mode. + You should be able to load it into your Emacs config and enable onyx-mode to get syntax highlighting. +

+
+ +
+

Language Server

+
+
+

+ If you are unfamiliar, a Language Server abstracts the tooling and language specific functionality out of editors and into a reusable component. + This way, it is easier to develop in-editor functionality across multiple editors, as the same work does not need to be replicated for each supported editor. +

+ +

Installing the Language Server

+

On Linux, MacOS, or the Windows Subsystem for Linux, run the following commands.

+
# Clone the Onyx Language Server
+git clone https://github.com/onyx-lang/onyx-lsp
+cd onyx-lsp/run_tree
+# Make the install script executable
+chmod +x ./install
+# Install the LSP
+./install
+ +

Visual Studio Code

+

Installing the extension automatically enables the language server in VS Code.

+ +

Neovim

+

To use the language server in NeoVim, you need to have the NeoVim lspconfig package installed.

+

Then, you need the following in your NeoVim configuration somewhere:

+
local lspconfig = require 'lspconfig'
+local configs = require 'lspconfig.configs'
+
+configs.onyx = {
+    default_config = {
+        cmd = { "onyx", "lsp" },
+        filetypes = { "onyx" },
+        root_dir = function(filename)
+            local utils = require "lspconfig.util"
+            return utils.search_ancestors(filename, function(path)
+                if utils.path.is_file(utils.path.join(path, "onyx-lsp.ini")) then
+                    return path
+                end
+            end)
+        end;
+        settings = {}
+    }
+}
+
+lspconfig.onyx.setup {
+    on_attach = function(client)
+        print("Onyx LSP started.")
+    end
+}
+ +

Sublime Text

+

+ Install the LSP package, and add the following custom configuration. + See more information on the LSP package docs. +

+
{
+  "clients": {
+    "onyx": {
+      "enabled": true,
+      "command": ["onyx", "lsp"],
+      "selector": "source.onyx"
+    }
+  }
+}
+
+ +{{ endblock }} + +{{ extends "pages/normal_page" }} diff --git a/www/templates/pages/docs/getting_started.html b/www/templates/pages/docs/getting_started.html new file mode 100644 index 0000000..b134c50 --- /dev/null +++ b/www/templates/pages/docs/getting_started.html @@ -0,0 +1,83 @@ +{{ block "title" }} + Getting Started +{{ endblock }} + +{{ block "page_content" }} + +
+

Getting Started

+
+ +
+

+ This short guide will walk you through getting Onyx installed on your system, creating your first project, and running your first program. + There are more in-depths guides after this one. +

+
+ +
+

Step 1: Install Onyx

+

On any Linux, MacOS, or WSL system, run the following command to install Onyx onto your system.

+
sh <(curl https://get.onyxlang.io -sSfL)
+ +

+ For more details, or how to install on Windows, see the installation docs. +

+
+ +
+

Step 2: Create an Onyx project

+ +

+ This is an optional step, but does set you up to use packages in your project. + Learn more about the package manager here. +

+ +

Create a new directory and setup a new project. Optionally project values when prompted.

+
$ mkdir my-onyx-project
+$ cd my-onyx-project
+$ onyx pkg init
+Creating new project manifest in ./onyx-pkg.kdl.
+
+Package name: my-onyx-project
+Package description: My first Onyx project
+Package url: 
+Package author: Brendan Hansen
+Package version (0.0.1):
+
+ +
+

Step 3: Write your first Onyx program

+

+ Open your favorite text editor, optionally install editor support, and create a new file called main.onyx in this project folder. + Write the following code in that file. +

+
use core {printf}
+
+main :: () {
+    printf("Hello, Onyx!\n");
+}
+ +

+ This code brings in the printf symbol from the core libraries so we can print to the console. + Then in the main function, we print "Hello, Onyx!". +

+
+ +
+

Step 4: Run your program!

+

To run the program our newly created program, we use the following command from within the project folder.

+
$ onyx run main.onyx
+Hello, Onyx!
+ +

+ Congratulations! You just wrote your first Onyx program. +

+

+ Now you can read the docs and experiment with Onyx in this project. +

+
+ +{{ endblock }} + +{{ extends "pages/normal_page" }} \ No newline at end of file diff --git a/www/templates/pages/docs/setup.html b/www/templates/pages/docs/setup.html deleted file mode 100644 index 0991567..0000000 --- a/www/templates/pages/docs/setup.html +++ /dev/null @@ -1,163 +0,0 @@ -{{block "title"}}Onyx Environment Setup{{endblock}} - -{{ let navbar_page = "docs" }} - -{{ block "page_content" }} - -
-

Setting Up Your Environment for Onyx

- -

The following sections will help set up an environment for you to program Onyx effectively.

- -

- VS Code - Vim / Neovim - Sublime text - Emacs - Language Server -

- -

- (If you don't see your favorite editor here, consider making a issue!) -

-
- - -
-

Visual Studio Code

-
-
-

- VS Code Extension -

- -

- Onyx has an official published extension on the Visual Studio Marketplace. - Search "Onyx Programming Language" in the extensions panel or install from the marketplace. -

- -

Alternatively, you can follow these steps to install the extension from the VSIX file included in the Onyx distribution.

-
    -
  1. Hit "Control+Shift+P" on Windows/Linux, or "Command+Shift+P" on MacOS.
  2. -
  3. Search for and select "Extensions: Install from VSIX".
  4. -
  5. Go to your ONYX_PATH and select the .vsix file in the misc folder.

  6. -
  7. Restart VS Code.
  8. -
- -

This extension does have support for the onyx lsp, assuming that is setup. -

- -
-

Vim / Neovim

-
-
-

- Vim Plugin -

- -

- Follow the instructions on the onyx.vim GitHub repo. -

- -

- Note, that this extension currently does not setup the LSP. - That must be done separately. -

-
- - -
-

Sublime Text

-
-
-

- Currently, Onyx does not have a published package on Sublime Text's Package Control, but like VS Code, you are able to install it manually. -

-

- In the misc folder of your installation, there is a file called onyx.sublime-syntax. Simply copy this into the Packages/User folder for Sublime Text. See more details here. -

-
- -
-

Emacs

-
-
-

- Currently, Onyx does not have a published package for Emacs. -

- -

- However, in the misc folder, there is an Emacs Lisp file that provides an onyx-mode. - You should be able to load it into your Emacs config and enable onyx-mode to get syntax highlighting. -

-
- -
-

Language Server

-
-
-

- If you are unfamiliar, a Language Server abstracts the tooling and language specific functionality out of editors and into a reusable component. - This way, it is easier to develop in-editor functionality across multiple editors, as the same work does not need to be replicated for each supported editor. -

- -

Installing the Language Server

-

On Linux, MacOS, or the Windows Subsystem for Linux, run the following commands.

-
# Clone the Onyx Language Server
-git clone https://github.com/onyx-lang/onyx-lsp
-cd onyx-lsp/run_tree
-# Make the install script executable
-chmod +x ./install
-# Install the LSP
-./install
- -

Visual Studio Code

-

Installing the extension automatically enables the language server in VS Code.

- -

Neovim

-

To use the language server in NeoVim, you need to have the NeoVim lspconfig package installed.

-

Then, you need the following in your NeoVim configuration somewhere:

-
local lspconfig = require 'lspconfig'
-local configs = require 'lspconfig.configs'
-
-configs.onyx = {
-    default_config = {
-        cmd = { "onyx", "lsp" },
-        filetypes = { "onyx" },
-        root_dir = function(filename)
-            local utils = require "lspconfig.util"
-            return utils.search_ancestors(filename, function(path)
-                if utils.path.is_file(utils.path.join(path, "onyx-lsp.ini")) then
-                    return path
-                end
-            end)
-        end;
-        settings = {}
-    }
-}
-
-lspconfig.onyx.setup {
-    on_attach = function(client)
-        print("Onyx LSP started.")
-    end
-}
- -

Sublime Text

-

- Install the LSP package, and add the following custom configuration. - See more information on the LSP package docs. -

-
{
-  "clients": {
-    "onyx": {
-      "enabled": true,
-      "command": ["onyx", "lsp"],
-      "selector": "source.onyx"
-    }
-  }
-}
-
- -{{ endblock }} - -{{ extends "pages/normal_page" }}