Giter Site home page Giter Site logo

rayso.nvim's Introduction

Create code snippets in Neovim using ray.so

Requirements

Neovim 0.8+

Installation

return {
  'TobinPalmer/rayso.nvim',
  cmd = { 'Rayso' },
  config = function()
    require('rayso').setup {}
  end
}

Configuration

These are the default options, you don't need to copy them into setup()

require('rayso').setup {
  base_url = 'https://ray.so/', -- Default URL
  open_cmd = 'firefox', -- On MacOS, will open with open -a firefox.app. Other OS's are untested.
  options = {
    background = true, -- If the screenshot should have a background.
    dark_mode = true, -- If the screenshot should be in dark mode.
    logging_path = '', -- Path to create a log file in.
    logging_file = 'rayso', -- Name of log file, will be a markdown file, ex rayso.md.
    logging_enabled = false, -- If you enable the logging file.
    padding = 32, -- The default padding that the screenshot will have.
    theme = 'crimson', -- Theme
    title = 'Untitled', -- Default title
  }
}

Example Config

return {
  'TobinPalmer/rayso.nvim',
  config = function()
    require('rayso').setup {
      open_cmd = 'chromium',
      options = {
        logging_path = '/Users/tobin/Documents/Rayso/', -- Notices the trailing slash
        logging_file = 'rayso',
        logging_enabled = true,
        theme = 'midnight',
      },
    }
    vim.keymap.set('v', '<leader>rs', require('lib.create').create_snippet)
  end,
}

Log File

The most powerful feature of this plugin is its ability to log snippets in a file, creating a time capsule of snippets This is an example of a log file. Log files will show the first 5 lines of the snippet, then cut off and show the link to the full snippet.

Source

```lua
---@param file string
---@return boolean
local function file_exists(file)
  local f = io.open(file, 'rb')
  if f then
...
```

[link](https://ray.so/#language=lua&theme=midnight&padding=32&code=LS0tQHBhcmFtIGZpbGUgc3RyaW5nCi0tLUByZXR1cm4gYm9vbGVhbgpsb2NhbCBmdW5jdGlvbiBmaWxlX2V4aXN0cyhmaWxlKQogIGxvY2FsIGYgPSBpby5vcGVuKGZpbGUsICdyYicpCiAgaWYgZiB0aGVuCiAgICBmOmNsb3NlKCkKICBlbmQKICByZXR1cm4gZiB%2BPSBuaWwKZW5k&title=Untitled&background=true&darkMode=true&)

```lua
-- Gets the open command from the config
local function get_open_command()
  -- On a mac
  if vim.fn.has('macunix') then
    return 'open -a ' .. M.config.open_cmd .. '.app'
...
```

[link](https://ray.so/#language=lua&theme=midnight&padding=32&code=LS0gR2V0cyB0aGUgb3BlbiBjb21tYW5kIGZyb20gdGhlIGNvbmZpZwpsb2NhbCBmdW5jdGlvbiBnZXRfb3Blbl9jb21tYW5kKCkKICAtLSBPbiBhIG1hYwogIGlmIHZpbS5mbi5oYXMoJ21hY3VuaXgnKSB0aGVuCiAgICByZXR1cm4gJ29wZW4gLWEgJyAuLiBNLmNvbmZpZy5vcGVuX2NtZCAuLiAnLmFwcCcKICBlbmQKCiAgLS0gTm90IGFuIG1hYyBhbmQgY29tbWFuZCBpcyBub3QgYW4gZXhlY3V0YWJsZQogIGlmIHZpbS5mbi5leGVjdXRhYmxlKE0uY29uZmlnLm9wZW5fY21kKSA9PSAwIHRoZW4KICAgIHJldHVybiBlcnJvcignQ291bGQgbm90IGZpbmQgZXhlY3V0YWJsZSBmb3IgJyAuLiBNLmNvbmZpZy5vcGVuX2NtZCkKICBlbmQKCiAgcmV0dXJuIE0uY29uZmlnLm9wZW5fY21kCmVuZA%3D%3D&title=Untitled&background=true&darkMode=true&)

Rendered Output

image

Inspiration

I took some code and major inspiration from Carbon Now

rayso.nvim's People

Contributors

proatgram avatar tobinpalmer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

rayso.nvim's Issues

Platform Support

It's unclear the platforms supported by this plugin.

I ran into this error on my first try:

Screenshot_2024_0628_212809

Saying:

Error executing Lua callback: ...ome/.local/share/nvim/lazy/rayso.nvim/lua/lib/create.lua:51: Could not find executable for chromium
stack traceback:
	[C]: in function 'get_open_command'
	...ome/.local/share/nvim/lazy/rayso.nvim/lua/lib/create.lua:51: in function 'create_snippet'
	...ome/.local/share/nvim/lazy/rayso.nvim/lua/lib/create.lua:97: in function <...ome/.local/share/nvim/lazy/rayso.nvim/lua/lib/create.lua:96>

Here's my Lazy.nvim config:

{
  'TobinPalmer/rayso.nvim',
  cmd = { 'Rayso' },
  config = function()
    require('rayso').setup {
        open_cmd = 'chromium'       
      }
  end
}, 

I came to GitHub to check and figured what was returning the error:


Screenshot_2024_0628_213249


The Docs should be updated if there isn't going to be a fix.

Fails to launch ray.so; almost certainly a skill issue

Hey there, I'm super excited to try this plugin but having some issues getting it to work and hoping someone out there can assist me.

lua/plugins/rayso.lua

return {
  "TobinPalmer/rayso.nvim",
  cmd = { "Rayso" },
  config = function()
    require("rayso").setup({
      open_cmd = "Arc",
      base_url = "https://ray.so/",
      options = {
        background = true,
        dark_mode = true,
        theme = "breeze",
        logging_enabled = true,
        logging_path = "/Users/nexxai/Documents/Rayso/",
        logging_file = "rayso.md",
        title = "nexxai",
        padding = 32,
      },
    })
  end,
}

If I enter visual mode, select some text and do :Rayso, I get this error message:
Screenshot 2024-02-29 at 2 27 39 PM

Can anyone see what I'm doing wrong here?

Unintended emphasized lines

Dear all,

I just have started to configure and use this. Most things are excellent, but the generated image automatically emphasizes the first three lines of code. It's not the behavior I want. How can I configure this to remove the emphasis? I'm trying this on the M1 Macbook Pro.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.