Skip to content

Instantly share code, notes, and snippets.

@dharmx
dharmx / class.lua
Last active February 20, 2024 17:20
Sort class items inside HTML.
View class.lua
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.
View cd.lua
---@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.
View permalink.lua
@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.
View ethos.lua
---@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.
@dharmx
dharmx / close.lua
Created October 29, 2023 16:32
Neovim closinng dialogbox (depends on NUI)
View close.lua
local Menu = require("nui.menu")
local NuiText = require("nui.text")
local popup_options = {
size = { width = 20, height = 4 },
position = {
row = "50%",
col = "50%",
},
border = {
@dharmx
dharmx / sort.lua
Created October 29, 2023 16:17
Sort TailwindCSS classes.
View sort.lua
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 / desktop.py
Created August 18, 2023 12:11
A python script for making a dock in Eww.
View desktop.py
#!/usr/bin/env python
import json
from pathlib import Path
from sys import stdout
from typing import Any, Callable, Dict, List
import gi
gi.require_version("Gtk", "3.0")
@dharmx
dharmx / eww.yuck
Last active July 25, 2023 08:11
Handle keys only when EWW window is open.
View eww.yuck
(defwindow window :windowtype "normal" :wm-ignore true
:geometry (geometry :anchor "center" :y 100 :width "10%" :height "10%")
(key))
(deflisten log "./key.sh")
(defwidget key[] "This prints nohing. '${log}'")
;; vim:filetype=yuck
@dharmx
dharmx / THEMES.md
Last active December 26, 2022 14:49
An exhaustive list of colorschemes.
View THEMES.md

LIST OF COLORSCHEMES

This is a generated themes list so, errors or, typos may exist. They are highly unlikely that they will be fixed. It is recommended to visit the source if you want ful clarity.

Themes are fetched from nvim-colo.

The 3024 Dark theme

@dharmx
dharmx / feline.lua
Last active February 3, 2024 15:16
Minimal feline configuration.
View feline.lua
local present, feline = pcall(require, "feline")
if not present then return end
-- Customizations {{{
local theme = {
aqua = "#7AB0DF",
bg = "#1C212A",
blue = "#5FB0FC",
cyan = "#70C0BA",
darkred = "#FB7373",