Skip to content

Instantly share code, notes, and snippets.

@dharmx
dharmx / on.lua
Created April 27, 2024 17:56
Sugar is sweet.
-- local on = require("on")
-- on.UILeave.CmdlineEnter:desc("test"):group("TEST"):prin("Test!"):only()()
return setmetatable({}, {
__index = function(_, event)
local params = { { event }, opts = {} }
local methods = {}
function methods:ex(cmd)
params.opts[type(cmd) == "string" and "command" or "callback"] = cmd
@dharmx
dharmx / gradle.lua
Last active March 28, 2024 20:49
IDEA-like command panel for Gradle.
-- place this at ~/.config/nvim/telescope/_extensions/gradle.lua
-- then require("telescope").load_extension("gradle") and rm these two lines
---@diagnostic disable: undefined-field
local J = require("plenary.job")
local Path = require("plenary.path")
local finders = require("telescope.finders")
local sorters = require("telescope.sorters")
local actions = require("telescope.actions")
local pickers = require("telescope.pickers")
@dharmx
dharmx / paste.lua
Created March 10, 2024 19:47
Pastebin.
local M = {}
local curl = require("plenary.curl")
local Path = require("plenary.path")
local Job = require("plenary.job")
M._responses = {}
M.config = {
db_path = vim.fn.stdpath("state") .. "/paste.db.json",
tmp_path = "/tmp/paste",
dump_path = "/tmp/dump",
@dharmx
dharmx / overview.lua
Last active March 8, 2024 19:37
NvChad Cheatsheet.
---@diagnostic disable: need-check-nil
local M = {}
local A = vim.api
local truncate = require("plenary.strings").truncate
M._line = -1
M._structure = {}
M._util_names = {
g = "gap",
c = "center",
@dharmx
dharmx / kao.lua
Created March 5, 2024 16:47
Kaomoji Picker!
-- put this in ~/nvim/lua/telescope/_extensions/kao.lua
-- then call require("telescope").load_extension("kao") after configuring telescope
local actions = require("telescope.actions")
local pickers = require("telescope.pickers")
local finders = require("telescope.finders")
local config = require("telescope.config")
local entry_display = require("telescope.pickers.entry_display")
local make_entry = require("telescope.make_entry")
local actions_state = require("telescope.actions.state")
@dharmx
dharmx / config.json
Last active February 23, 2024 19:21
Generate problem set for boosting mental calculations.
{
"multiply": {
"two": 20,
"three": 10
},
"add": {
"two": 10,
"three": 20,
"four": 10,
"five": 5
@dharmx
dharmx / class.lua
Last active February 20, 2024 17:20
Sort class items inside HTML.
local T = vim.treesitter
local query = T.query
-- caps indicate config values
local SORTERS = {}
SORTERS.ASCII = function(a, b) return string.byte(a:sub(1, 1)) > string.byte(b:sub(1, 1)) end
-- add more
local SELECTED_SORTERS = { SORTERS.ASCII } -- add more
local FILETYPE = vim.o.filetype
@dharmx
dharmx / cd.lua
Created October 30, 2023 18:08
Fuzzily change cwd based off of the lines in the current buffer. Works well with oil.nvim.
---@brief [[
---Get lines from a buffer > feed the lines into telescope\
---Choose from the entries
---See if the chosen entry is a directory
---If yes then run :chd <chosen> else do nothing
---@brief ]]
local finders = require("telescope.finders")
local pickers = require("telescope.pickers")
local config = require("telescope.config")
@dharmx
dharmx / permalink.lua
Created October 30, 2023 05:13
Generate a permanent link to a file or, line of your GitHub repository.
@dharmx
dharmx / ethos.lua
Created October 30, 2023 02:07
Get meanings, examples, antonyms and synonyms of a word using dictd in Neovim. This supports multiple sources like urban dictionary.
---@diagnostic disable: cast-local-type, param-type-mismatch, assign-type-mismatch, need-check-nil, undefined-field
-- TODO:
-- + Add UI, HL and mapping options.
-- + Cleanup buffers.
-- + Use namespaces and add_highlights.
-- + Calculate floating window width.
-- + Add a telescope extension.
-- + Variable name suggestor.
-- + Write docs.