GithubHelp home page GithubHelp logo

vyfor / discord.nvim Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cyuria/discord.nvim

1.0 0.0 0.0 3.77 MB

my own take on the discord rich presence plugin in neovim

License: MIT License

C++ 38.79% Lua 46.26% CMake 14.94%

discord.nvim's Introduction

discord.nvim

my own take on the discord rich presence plugin in neovim

Features

  • It should be cross-platform (only tested on windows 10 currently)
  • It doesn't ruin my neovim config
  • Easy to use and unobtrusive
  • Uses CWD as "project" (And therefore works with plugins like ahmedkhalf/project.nvim, for example)
  • Only requires cmake and a C++ compiler, no neovim plugin dependencies

Installation

Vim-Plug

Plug 'Cyuria/discord.nvim', { 'do': 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' }

Other

It should be basically the same as any other plugin manager, just make sure to run the following command whenever you install or update:

cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build

Usage

Almost everything is done automagically, but you do need to call require'discord'.setup() to add all the autocmds and user commands.

Setup

You need to run require'discord'.setup() for the plugin to start doing anything. setup takes an optional table argument, default initialised with the following values:

local DEFAULT_OPTS = {
    usercmd = true, -- setup user commands
    autocmd = true, -- setup autocommands for updating on file change
    initonenter = true, -- setup autocommand to start on VimEnter
    quitonleave = true, -- setup autocommand to stop on VimLeavePre (important for cleanup stuff, just leave as true regardless)
}

Caveats

Won't work if discord is started after neovim, start discord and then reload neovim

The plugin also won't work if it is already running, it will give you the following error:

Discord: Something went wrong while copying and/or loading library files
Discord.nvim Failed to start because the C++ library could not be copied or is in use

Just ignore it if this happens

Commands

Vim

  • :DiscordInit | Start talking to discord (not called automatically)
    • No Arguments
  • :DiscordStop | Shutdown discord, do this for cleanup, it doesn't break anything if discord hasn't been initialised yet
    • No Arguments
  • :DiscordChwd | Manually change displayed working directory, has no effect on actual working directory
    • Two arguments, new folder name and new filename
    • Automatically resets elapsed time
  • :DiscordFile | Manually change the displayed file, has no effect on neovim
    • One argument, new file name
  • :DiscordFNum | Manually change the "number of files" value shown in discord "(x of y)"
    • Two arguments, current file number and total number of files
  • :DiscordFExt | Manually change the file extension displayed by discord
    • One argument, new file extension

Lua

Assumes local discordPresence = require'discord' present

  • discordPresence.setup() | Setup plugin
  • discordPresence.init() | Start talking to discord
  • discordPresence.stop() | Stop talking to discord (also performs cleanup)
  • discordPresence.setFolder(folder, filename) | Set a new folder and filename to be displayed
    • Automatically resets elapsed time
  • discordPresence.setFile(filename) | Set the file to be displayed
  • discordPresence.setFileNums(currentfile, totalfilenum) | Set the "number of files" value shown in discord "(currentfile of totalfilenum)"
  • discordPresence.setExt(fileext) | Set the file extension to be used

Why I Made It

I was using andweeb/presence.nvim for this exact purpose, but it had a weird issue where neovim would hang randomly for up to thirty seconds after closing. I haven't had this issue with my plugin, also I wanted to write a neovim plugin, otherwise I probably would have used another alternative.

Also I prefer the discord presentation layout in this plugin (naturally, I made it)

Credits, Inspiration and Alternatives

I copy pasted almost the entire CMakeLists.txt from the one at nvim-telescope/telescope-fzf-native.nvim I also copied some other parts of the code from there.

I was previously using andweeb/presence.nvim and took inspiration as well as the list of file extension to language mapping data from there.

A large chunk of the code comes from discord-rpc, which is now deprecated, but still works fine and I don't want to learn or use the entire discord SDK for this.

discord.nvim's People

Contributors

cyuria avatar vyfor avatar

Stargazers

 avatar

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.