cerulean
This commit is contained in:
parent
ac95603fc4
commit
61b531aa11
42 changed files with 1061 additions and 445 deletions
28
homes/dea/default.nix
Normal file
28
homes/dea/default.nix
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
inputs,
|
||||
root,
|
||||
...
|
||||
}: {
|
||||
home.username = "dea";
|
||||
home.homeDirectory = "/home/dea";
|
||||
home.sessionPath = [
|
||||
"$HOME/.local/bin"
|
||||
];
|
||||
|
||||
imports = [
|
||||
inputs.plasma-manager.homeModules.plasma-manager
|
||||
|
||||
/${root}/homes/modules/bash
|
||||
/${root}/homes/modules/starship
|
||||
/${root}/homes/modules/vim
|
||||
/${root}/homes/modules/mpv
|
||||
];
|
||||
|
||||
programs.plasma = {
|
||||
enable = true;
|
||||
kwin.edgeBarrier = 50;
|
||||
};
|
||||
|
||||
# DO NOT MODIFY
|
||||
home.stateVersion = "25.11";
|
||||
}
|
||||
17
homes/modules/bash/bashrc
Normal file
17
homes/modules/bash/bashrc
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
eval "$(starship init bash)"
|
||||
|
||||
alias eep='systemctl suspend'
|
||||
alias hibernate='systemctl hybrid-sleep'
|
||||
alias restart='systemctl reboot'
|
||||
alias shutdown='systemctl poweroff'
|
||||
alias vim='dvim'
|
||||
alias nvim='dvim'
|
||||
rebuild() {
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
sudo nixos-rebuild switch --flake ~/dea-files#"$(hostname)"
|
||||
else
|
||||
sudo nixos-rebuild switch --flake ~/dea-files#"$1"
|
||||
fi
|
||||
}
|
||||
[ -f "/home/dea/.ghcup/env" ] && . "/home/dea/.ghcup/env" # ghcup-env
|
||||
6
homes/modules/bash/default.nix
Normal file
6
homes/modules/bash/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{...}: {
|
||||
programs.bash = {
|
||||
enable = true;
|
||||
bashrcExtra = builtins.readFile ./bashrc;
|
||||
};
|
||||
}
|
||||
87
homes/modules/mpv/default.nix
Normal file
87
homes/modules/mpv/default.nix
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
{ pkgs, ... }:
|
||||
let
|
||||
auto-sub =
|
||||
let
|
||||
file = builtins.toFile "auto-sub.lua" ''
|
||||
mp.add_hook('on_load', 10, function ()
|
||||
mp.set_property('sub-file-paths', 'Subs/' .. mp.get_property('filename/no-ext'))
|
||||
end)
|
||||
'';
|
||||
in
|
||||
pkgs.mpvScripts.buildLua {
|
||||
pname = "auto-sub";
|
||||
version = "1.0.0";
|
||||
src = file;
|
||||
unpackPhase = ":";
|
||||
scriptPath = file;
|
||||
};
|
||||
seek-end =
|
||||
let
|
||||
file = builtins.toFile "seek_end.lua" ''
|
||||
function seek_end()
|
||||
mp.commandv("seek", math.floor(mp.get_property_number("duration") - 4), "absolute")
|
||||
end
|
||||
mp.add_key_binding(nil, "seek_end", seek_end)
|
||||
'';
|
||||
in
|
||||
pkgs.mpvScripts.buildLua {
|
||||
pname = "seek-end";
|
||||
version = "1.0.0";
|
||||
src = file;
|
||||
unpackPhase = ":";
|
||||
scriptPath = file;
|
||||
};
|
||||
in
|
||||
{
|
||||
programs.mpv = {
|
||||
enable = true;
|
||||
config = {
|
||||
input-default-bindings = false;
|
||||
input-builtin-bindings = false;
|
||||
|
||||
sub-outline-color = "0.0/0.3";
|
||||
sub-border-style = "opaque-box";
|
||||
sub-outline-size = -2;
|
||||
sub-filter-regex-append = "opensubtitles\\.org";
|
||||
sub-auto = "all";
|
||||
|
||||
ytdl-format = "bestvideo+bestaudio/best";
|
||||
slang = "en";
|
||||
ytdl-raw-options = "ignore-config=,sub-lang=en,write-sub=,write-auto-sub=";
|
||||
|
||||
hidpi-window-scale = false;
|
||||
hwdec = "auto";
|
||||
profile = "high-quality";
|
||||
vulkan-swap-mode = "auto";
|
||||
gpu-context = "wayland";
|
||||
};
|
||||
bindings = {
|
||||
"]" = "add speed 0.5";
|
||||
"[" = "add speed -0.5";
|
||||
SPACE = "cycle pause";
|
||||
RIGHT = "seek 5 exact";
|
||||
LEFT = "seek -5 exact";
|
||||
v = "cycle sub";
|
||||
V = "cycle sub down";
|
||||
b = "cycle audio";
|
||||
B = "cycle audio down";
|
||||
f = "cycle fullscreen";
|
||||
WHEEL_UP = "add volume 2";
|
||||
WHEEL_DOWN = "add volume -2";
|
||||
j = "add chapter -1";
|
||||
l = "add chapter 1";
|
||||
y = "script-binding seek_end";
|
||||
"`" = "script-binding console/enable";
|
||||
};
|
||||
scripts =
|
||||
with pkgs.mpvScripts;
|
||||
[
|
||||
mpv-osc-tethys
|
||||
thumbfast
|
||||
]
|
||||
++ [
|
||||
seek-end
|
||||
auto-sub
|
||||
];
|
||||
};
|
||||
}
|
||||
8
homes/modules/starship/default.nix
Normal file
8
homes/modules/starship/default.nix
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{...}: {
|
||||
programs.starship = {
|
||||
enable = true;
|
||||
settings =
|
||||
builtins.readFile ./starship.toml
|
||||
|> builtins.fromTOML;
|
||||
};
|
||||
}
|
||||
57
homes/modules/starship/starship.toml
Normal file
57
homes/modules/starship/starship.toml
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
# Inserts a blank line between shell prompts
|
||||
add_newline = true
|
||||
|
||||
# Replace the '❯' symbol in the prompt with '➜'
|
||||
#[character] # The name of the module we are configuring is 'character'
|
||||
#success_symbol = '[➜ ](bold fg:207)' # The 'success_symbol' segment is being set to '➜' with the color 'bold pink'
|
||||
|
||||
format = """
|
||||
$directory\
|
||||
$character"""
|
||||
|
||||
[directory]
|
||||
truncation_length = 3
|
||||
truncate_to_repo = false
|
||||
format = "[$path]($style) [❤](bold fg:207) "
|
||||
style = "bold cyan"
|
||||
|
||||
[character]
|
||||
success_symbol = ""
|
||||
error_symbol = ""
|
||||
|
||||
#====
|
||||
|
||||
#[directory]
|
||||
#format = "[$path](bold bright-green) [❤](#ff69b4) "
|
||||
#
|
||||
#[character]
|
||||
#disabled = true
|
||||
#
|
||||
# Disable all other modules
|
||||
#[git_branch]
|
||||
#disabled = true
|
||||
#
|
||||
#[git_commit]
|
||||
#disabled = true
|
||||
#
|
||||
#[git_state]
|
||||
#disabled = true
|
||||
#
|
||||
#[git_status]
|
||||
#disabled = true
|
||||
#
|
||||
#[cmd_duration]
|
||||
#disabled = true
|
||||
#
|
||||
# (Optional) Disable other modules you might see
|
||||
#[package]
|
||||
#disabled = true
|
||||
#
|
||||
#[python]
|
||||
#disabled = true
|
||||
#
|
||||
#[nodejs]
|
||||
#disabled = true
|
||||
#
|
||||
#[rust]
|
||||
#disabled = true
|
||||
1
homes/modules/vim/default.nix
Normal file
1
homes/modules/vim/default.nix
Normal file
|
|
@ -0,0 +1 @@
|
|||
import ./nixcats.nix
|
||||
11
homes/modules/vim/init.lua
Normal file
11
homes/modules/vim/init.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
vim.g.mapleader = " "
|
||||
|
||||
vim.opt.termguicolors = true -- use terminal colors
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.number = true
|
||||
vim.opt.wrap = true
|
||||
-- vim.opt.colorcolumn = "80"
|
||||
vim.cmd.colorscheme("candyland")
|
||||
|
||||
require("plugins")
|
||||
require("lsp")
|
||||
59
homes/modules/vim/lua/lsp/capabilities.lua
Normal file
59
homes/modules/vim/lua/lsp/capabilities.lua
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
local M = {}
|
||||
|
||||
function M.on_attach(_, bufnr)
|
||||
-- we create a function that lets us more easily define mappings specific
|
||||
-- for LSP related items. It sets the mode, buffer and description for us each time.
|
||||
|
||||
local nmap = function(keys, func, desc)
|
||||
if desc then
|
||||
desc = 'LSP: ' .. desc
|
||||
end
|
||||
|
||||
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
|
||||
end
|
||||
|
||||
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
||||
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
|
||||
|
||||
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
|
||||
|
||||
-- NOTE: why are these functions that call the telescope builtin?
|
||||
-- because otherwise they would load telescope eagerly when this is defined.
|
||||
-- due to us using the on_require handler to make sure it is available.
|
||||
if nixCats('general.telescope') then
|
||||
nmap('gr', function() require('telescope.builtin').lsp_references() end, '[G]oto [R]eferences')
|
||||
nmap('gI', function() require('telescope.builtin').lsp_implementations() end, '[G]oto [I]mplementation')
|
||||
nmap('<leader>ds', function() require('telescope.builtin').lsp_document_symbols() end, '[D]ocument [S]ymbols')
|
||||
nmap('<leader>ws', function() require('telescope.builtin').lsp_dynamic_workspace_symbols() end, '[W]orkspace [S]ymbols')
|
||||
nmap('<leader>dd', "<cmd>Telescope diagnostics bufnr=0<CR>", '[D]ocument [D]iagnostics')
|
||||
nmap('<leader>wd', "<cmd>Telescope diagnostics<CR>", '[W]orkspace [D]iagnostics')
|
||||
end -- TODO: someone who knows the builtin versions of these to do instead help me out please.
|
||||
|
||||
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
|
||||
nmap('<leader>e', vim.diagnostic.open_float, 'Show [E]rror')
|
||||
|
||||
-- See `:help K` for why this keymap
|
||||
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
|
||||
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
|
||||
|
||||
-- Lesser used LSP functionality
|
||||
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
|
||||
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
|
||||
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
|
||||
nmap('<leader>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, '[W]orkspace [L]ist Folders')
|
||||
|
||||
-- Create a command `:Format` local to the LSP buffer
|
||||
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
|
||||
vim.lsp.buf.format()
|
||||
end, { desc = 'Format current buffer with LSP' })
|
||||
|
||||
end
|
||||
|
||||
function M.get(server_name)
|
||||
local capabilities = require('blink.cmp').get_lsp_capabilities()
|
||||
|
||||
return capabilities
|
||||
end
|
||||
return M
|
||||
88
homes/modules/vim/lua/lsp/completion.lua
Normal file
88
homes/modules/vim/lua/lsp/completion.lua
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
return {
|
||||
{
|
||||
"friendly-snippets",
|
||||
dep_of = { "blink.cmp" },
|
||||
},
|
||||
{
|
||||
"blink.cmp",
|
||||
event = { "InsertEnter", "CmdlineEnter" },
|
||||
on_require = "blink",
|
||||
load = function (name)
|
||||
vim.cmd.packadd(name)
|
||||
end,
|
||||
after = function(plugin)
|
||||
local blink = require('blink.cmp')
|
||||
|
||||
blink.setup({
|
||||
keymap = {
|
||||
preset = 'default',
|
||||
},
|
||||
|
||||
appearance = {
|
||||
nerd_font_variant = 'mono',
|
||||
},
|
||||
|
||||
sources = {
|
||||
default = { 'lsp', 'path', 'snippets', 'buffer' },
|
||||
providers = {
|
||||
lsp = {
|
||||
name = 'LSP',
|
||||
module = 'blink.cmp.sources.lsp',
|
||||
enabled = true,
|
||||
},
|
||||
path = {
|
||||
name = 'Path',
|
||||
module = 'blink.cmp.sources.path',
|
||||
enabled = true,
|
||||
},
|
||||
snippets = {
|
||||
name = 'Snippets',
|
||||
module = 'blink.cmp.sources.snippets',
|
||||
enabled = true,
|
||||
},
|
||||
buffer = {
|
||||
name = 'Buffer',
|
||||
module = 'blink.cmp.sources.buffer',
|
||||
enabled = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
completion = {
|
||||
accept = {
|
||||
auto_brackets = {
|
||||
enabled = true,
|
||||
},
|
||||
},
|
||||
|
||||
menu = {
|
||||
border = 'rounded',
|
||||
max_height = 12,
|
||||
scrolloff = 2,
|
||||
|
||||
draw = {
|
||||
columns = {
|
||||
{ "kind_icon", gap = 1, },
|
||||
{ "label", "label_description", gap = 1, },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
documentation = {
|
||||
auto_show = false,
|
||||
window = {
|
||||
border = 'rounded',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
signature = {
|
||||
enabled = true,
|
||||
window = {
|
||||
border = 'rounded',
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
},
|
||||
}
|
||||
17
homes/modules/vim/lua/lsp/indentation.lua
Normal file
17
homes/modules/vim/lua/lsp/indentation.lua
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "lua",
|
||||
callback = function()
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.opt_local.tabstop = 2
|
||||
vim.opt_local.expandtab = true
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "nix",
|
||||
callback = function()
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.opt_local.tabstop = 2
|
||||
vim.opt_local.expandtab = true
|
||||
end,
|
||||
})
|
||||
6
homes/modules/vim/lua/lsp/init.lua
Normal file
6
homes/modules/vim/lua/lsp/init.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
require("lze").load {
|
||||
{ import = "lsp.completion", },
|
||||
}
|
||||
|
||||
require("lsp.indentation")
|
||||
require("lsp.lsp")
|
||||
95
homes/modules/vim/lua/lsp/lsp.lua
Normal file
95
homes/modules/vim/lua/lsp/lsp.lua
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
local servers = {}
|
||||
|
||||
servers.lua_ls = {
|
||||
settings = {
|
||||
Lua = {
|
||||
formatters = {
|
||||
ignoreComments = false,
|
||||
},
|
||||
signatureHelp = { enable = true },
|
||||
diagnostics = {
|
||||
globals = { "nixCats", "vim" },
|
||||
-- disable = { 'missing-fields' },
|
||||
},
|
||||
workspace = {
|
||||
-- make the server aware of the neovim runtime files
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
checkThirdParty = false,
|
||||
},
|
||||
},
|
||||
telemetry = { enabled = false },
|
||||
},
|
||||
}
|
||||
|
||||
servers.nil_ls = {
|
||||
settings = {},
|
||||
}
|
||||
|
||||
local rust_analyzer_cmd = os.getenv("RUST_ANALYZER_CMD")
|
||||
servers.rust_analyzer = {
|
||||
cmd = { rust_analyzer_cmd },
|
||||
settings = {
|
||||
server = {
|
||||
-- For debugging rust-analyzer, to see log location do :LspInfo in neovim
|
||||
-- extraEnv = { {["RA_LOG"]="project_model=debug"} },
|
||||
},
|
||||
cargo = {
|
||||
allFeatures = false,
|
||||
allTargets = false,
|
||||
buildScripts = { enable = true },
|
||||
target = "x86_64-unknown-linux-gnu",
|
||||
},
|
||||
diagnostics = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
servers.hls = {
|
||||
settings = {},
|
||||
}
|
||||
|
||||
-- Taken from nixCats example:
|
||||
-- If you were to comment out this autocommand
|
||||
-- and instead pass the on attach function directly to
|
||||
-- nvim-lspconfig, it would do the same thing.
|
||||
-- come to think of it, it might be better because then lspconfig doesnt have to be called before lsp attach?
|
||||
-- but you would still end up triggering on a FileType event anyway, so, it makes little difference.
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("nixCats-lsp-attach", { clear = true }),
|
||||
callback = function(event)
|
||||
require("lsp.capabilities").on_attach(vim.lsp.get_client_by_id(event.data.client_id), event.buf)
|
||||
end,
|
||||
})
|
||||
|
||||
require("lze").load({
|
||||
{
|
||||
"nvim-lspconfig",
|
||||
event = "FileType",
|
||||
after = function(plugin)
|
||||
-- Just register configs, don't enable yet
|
||||
for server_name, cfg in pairs(servers) do
|
||||
vim.lsp.config(server_name, {
|
||||
capabilities = require("lsp.capabilities").get(server_name),
|
||||
settings = (cfg or {}).settings,
|
||||
filetypes = (cfg or {}).filetypes,
|
||||
cmd = (cfg or {}).cmd,
|
||||
root_pattern = (cfg or {}).root_pattern,
|
||||
})
|
||||
end
|
||||
|
||||
-- Enable on-demand per filetype
|
||||
for server_name, cfg in pairs(servers) do
|
||||
local filetypes = cfg.filetypes or vim.lsp.config[server_name].filetypes
|
||||
if filetypes then
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = filetypes,
|
||||
callback = function()
|
||||
vim.lsp.enable(server_name)
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
end,
|
||||
},
|
||||
})
|
||||
23
homes/modules/vim/lua/plugins/comment.lua
Normal file
23
homes/modules/vim/lua/plugins/comment.lua
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
return {
|
||||
{
|
||||
"comment.nvim",
|
||||
event = { "BufReadPost", "BufNewFile" },
|
||||
after = function(plugin)
|
||||
require("Comment").setup({
|
||||
toggler = {
|
||||
line = "<leader>cc",
|
||||
block = "<leader>bc",
|
||||
},
|
||||
opleader = {
|
||||
line = "<leader>c",
|
||||
block = "<leader>b",
|
||||
},
|
||||
extra = {
|
||||
above = "<leader>c<S-o>",
|
||||
below = "<leader>co",
|
||||
eol = "<leader>cA",
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
5
homes/modules/vim/lua/plugins/dressing.lua
Normal file
5
homes/modules/vim/lua/plugins/dressing.lua
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
return {
|
||||
{
|
||||
"dressing.nvim"
|
||||
},
|
||||
}
|
||||
33
homes/modules/vim/lua/plugins/format.lua
Normal file
33
homes/modules/vim/lua/plugins/format.lua
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
-- docs -> https://github.com/stevearc/conform.nvim
|
||||
return {
|
||||
{
|
||||
"conform.nvim",
|
||||
enabled = nixCats("format") or false,
|
||||
keys = {
|
||||
{ "<leader>p", desc = "Format File (pretty :3)" },
|
||||
},
|
||||
after = function(plugin)
|
||||
local conform = require("conform")
|
||||
|
||||
conform.setup({
|
||||
formatters_by_ft = {
|
||||
lua = nixCats("lang.lua") and { "stylua" } or nil,
|
||||
nix = nixCats("lang.nix") and { "nixfmt" } or nil,
|
||||
rust = nixCats("lang.rust") and { "rustfmt", lsp_format = "fallback" } or nil,
|
||||
haskell = nixCats("lang.haskell") and { "ormolu" } or nil,
|
||||
},
|
||||
format_on_save = {
|
||||
timeout_ms = 500,
|
||||
},
|
||||
})
|
||||
|
||||
vim.keymap.set({ "n", "v" }, "<leader>p", function()
|
||||
conform.format({
|
||||
lsp_fallback = false,
|
||||
async = false,
|
||||
timeout_ms = 1000,
|
||||
})
|
||||
end, { desc = "Format File (pretty :3)" })
|
||||
end,
|
||||
},
|
||||
}
|
||||
15
homes/modules/vim/lua/plugins/fyler.lua
Normal file
15
homes/modules/vim/lua/plugins/fyler.lua
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
return {
|
||||
{
|
||||
"fyler.nvim",
|
||||
cmd = { "Fyler" },
|
||||
keys = {
|
||||
{ "<leader>tf", function() return require('fyler').toggle({ kind = "split_right" }) end, mode = {"n"}, desc = 'Open [F]yler' },
|
||||
},
|
||||
load = function (name)
|
||||
vim.cmd.packadd(name)
|
||||
end,
|
||||
after = function(plugin)
|
||||
local fyler = require("fyler").setup()
|
||||
end,
|
||||
},
|
||||
}
|
||||
10
homes/modules/vim/lua/plugins/init.lua
Normal file
10
homes/modules/vim/lua/plugins/init.lua
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
require("lze").load({
|
||||
{ import = "plugins.dressing" },
|
||||
{ import = "plugins.telescope" },
|
||||
{ import = "plugins.treesitter" },
|
||||
{ import = "plugins.fyler" },
|
||||
{ import = "plugins.mini-hipatterns" },
|
||||
{ import = "plugins.orgmode" },
|
||||
{ import = "plugins.format" },
|
||||
{ import = "plugins.comment" },
|
||||
})
|
||||
76
homes/modules/vim/lua/plugins/mini-hipatterns.lua
Normal file
76
homes/modules/vim/lua/plugins/mini-hipatterns.lua
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
return {
|
||||
{
|
||||
"mini.hipatterns",
|
||||
after = function(plugin)
|
||||
local hipatterns = require("mini.hipatterns")
|
||||
|
||||
-- Returns hex color group for matching short hex color.
|
||||
--
|
||||
---@param match string
|
||||
---@return string
|
||||
local hex_color_short = function(_, match)
|
||||
local style = 'fg' -- 'fg' or 'bg', for extmark_opts_inline use 'fg'
|
||||
local r, g, b = match:sub(2, 2), match:sub(3, 3), match:sub(4, 4)
|
||||
local hex = string.format('#%s%s%s%s%s%s', r, r, g, g, b, b)
|
||||
return hipatterns.compute_hex_color_group(hex, style)
|
||||
end
|
||||
|
||||
-- Returns hex color group for matching alpha hex color.
|
||||
--
|
||||
---@param match string
|
||||
---@return string
|
||||
local hex_color_alpha = function(_, match)
|
||||
local style = 'fg' -- 'fg' or 'bg', for extmark_opts_inline use 'fg'
|
||||
local r, g, b = match:sub(2, 3), match:sub(4, 5), match:sub(6, 7)
|
||||
local hex = string.format('#%s%s%s', r, g, b)
|
||||
return hipatterns.compute_hex_color_group(hex, style)
|
||||
end
|
||||
|
||||
-- Returns extmark opts for highlights with virtual inline text.
|
||||
--
|
||||
---@param data table Includes `hl_group`, `full_match` and more.
|
||||
---@return table
|
||||
local extmark_opts_inline = function(_, _, data)
|
||||
return {
|
||||
virt_text = { { '', data.hl_group } },
|
||||
virt_text_pos = 'inline',
|
||||
right_gravity = false,
|
||||
}
|
||||
end
|
||||
|
||||
-- Returns extmark opts for highlights with virtual inline text.
|
||||
--
|
||||
---@param data table Includes `hl_group`, `full_match` and more.
|
||||
---@return table
|
||||
local extmark_opts_inline_alpha = function(_, _, data)
|
||||
return {
|
||||
virt_text = { { '', data.hl_group } },
|
||||
virt_text_pos = 'inline',
|
||||
right_gravity = false,
|
||||
}
|
||||
end
|
||||
|
||||
hipatterns.setup({
|
||||
highlighters = {
|
||||
-- #rrggbb
|
||||
hex_color = hipatterns.gen_highlighter.hex_color({
|
||||
style = "inline",
|
||||
inline_text = '',
|
||||
}),
|
||||
-- #rgb
|
||||
hex_color_short = {
|
||||
pattern = "#%x%x%x%f[%X]",
|
||||
group = hex_color_short,
|
||||
extmark_opts = extmark_opts_inline,
|
||||
},
|
||||
-- #rrggbbaa
|
||||
hex_color_alpha = {
|
||||
pattern = "#%x%x%x%x%x%x%x%x%f[%X]",
|
||||
group = hex_color_alpha,
|
||||
extmark_opts = extmark_opts_inline_alpha,
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
16
homes/modules/vim/lua/plugins/orgmode.lua
Normal file
16
homes/modules/vim/lua/plugins/orgmode.lua
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# options: https://github.com/nvim-orgmode/orgmode/blob/master/docs/installation.org
|
||||
return {
|
||||
{
|
||||
"orgmode",
|
||||
event = { "FileType" },
|
||||
ft = { "org" },
|
||||
after = function(plugin)
|
||||
require("orgmode").setup({
|
||||
org_agenda_files = "~/.orgmode/**/*",
|
||||
org_default_notes_file = "~/.orgmode/refile.org",
|
||||
})
|
||||
|
||||
vim.lsp.enable("org")
|
||||
end,
|
||||
},
|
||||
}
|
||||
78
homes/modules/vim/lua/plugins/telescope.lua
Normal file
78
homes/modules/vim/lua/plugins/telescope.lua
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
return {
|
||||
{
|
||||
"telescope.nvim",
|
||||
cmd = { "Telescope" },
|
||||
keys = {
|
||||
{
|
||||
"<leader>f",
|
||||
function()
|
||||
return require("telescope.builtin").find_files()
|
||||
end,
|
||||
mode = { "n" },
|
||||
desc = "Telescope search [F]iles",
|
||||
},
|
||||
{
|
||||
"<leader>tr",
|
||||
function()
|
||||
return require("telescope.builtin").oldfiles()
|
||||
end,
|
||||
mode = { "n" },
|
||||
desc = "[T]elescope search [R]ecent files",
|
||||
},
|
||||
{
|
||||
"<leader>ts",
|
||||
function()
|
||||
return require("telescope.builtin").live_grep()
|
||||
end,
|
||||
mode = { "n" },
|
||||
desc = "[T]elescope [S]earch cwd with grep",
|
||||
},
|
||||
{
|
||||
"<leader>tw",
|
||||
function()
|
||||
return require("telescope.builtin").grep_string()
|
||||
end,
|
||||
mode = { "n" },
|
||||
desc = "[T]elescope search current [W]ord",
|
||||
},
|
||||
{
|
||||
"<leader>tk",
|
||||
function()
|
||||
return require("telescope.builtin").keymaps()
|
||||
end,
|
||||
mode = { "n" },
|
||||
desc = "[T]elescope search [K]eymaps",
|
||||
},
|
||||
{
|
||||
"<leader>tb",
|
||||
function()
|
||||
return require("telescope.builtin").buffers()
|
||||
end,
|
||||
mode = { "n" },
|
||||
desc = "[T]elescope search [B]uffers",
|
||||
},
|
||||
},
|
||||
load = function(name)
|
||||
vim.cmd.packadd(name)
|
||||
vim.cmd.packadd("telescope-fzf-native.nvim")
|
||||
end,
|
||||
after = function(plugin)
|
||||
local telescope = require("telescope")
|
||||
local actions = require("telescope.actions")
|
||||
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-k>"] = actions.move_selection_previous, -- move to prev result
|
||||
["<C-j>"] = actions.move_selection_next, -- move to next result
|
||||
["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
pcall(telescope.load_extension, "fzf")
|
||||
end,
|
||||
},
|
||||
}
|
||||
95
homes/modules/vim/lua/plugins/treesitter.lua
Normal file
95
homes/modules/vim/lua/plugins/treesitter.lua
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
-- to help me write this after nvim-treesitter updated, i used:
|
||||
-- https://github.com/BirdeeHub/nixCats-nvim/blob/3c9bc4d7123e1b48d92f25ba505b889af541e897/templates/example/lua/myLuaConf/plugins/treesitter.lua
|
||||
|
||||
return {
|
||||
{
|
||||
"nvim-treesitter",
|
||||
lazy = false,
|
||||
after = function(plugin)
|
||||
--@param buf integer
|
||||
--@param language string
|
||||
local function treesitter_try_attach(buf, language)
|
||||
--check if parser exists and load it
|
||||
if not vim.treesitter.language.add(language) then
|
||||
return
|
||||
end
|
||||
|
||||
-- enables syntax highlight and other treesitter features
|
||||
vim.treesitter.start(buf, language)
|
||||
|
||||
-- enables treesitter based folds
|
||||
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
|
||||
|
||||
-- enables treesiter based indentation
|
||||
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
|
||||
end
|
||||
|
||||
local available_parsers = require("nvim-treesitter").get_available()
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
callback = function(args)
|
||||
local buf, filetype = args.buf, args.match
|
||||
local language = vim.treesitter.language.get_lang(filetype)
|
||||
if not language then
|
||||
return
|
||||
end
|
||||
|
||||
local installed_parsers = require("nvim-treesitter").get_installed("parsers")
|
||||
|
||||
if vim.tbl_contains(installed_parsers, language) then
|
||||
-- enable the parser if it is installed
|
||||
treesitter_try_attach(buf, language)
|
||||
elseif vim.tbl_contains(available_parsers, language) then
|
||||
-- if a parser is available in `nvim-treesitter` enable it after ensuring it is installed
|
||||
require("nvim-treesitter").install(language):await(function()
|
||||
treesitter_try_attach(buf, language)
|
||||
end)
|
||||
else
|
||||
-- try to enable treesitter features in case the parser exists but is not available from `nvim-treesitter`
|
||||
treesitter_try_attach(buf, language)
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nvim-treesitter-textobjects",
|
||||
lazy = false,
|
||||
before = function(plugin)
|
||||
vim.g.no_plugin_maps = true
|
||||
end,
|
||||
after = function(plugin)
|
||||
require("nvim-treesitter-textobjects").setup({
|
||||
select = {
|
||||
lookahead = true,
|
||||
selection_modes = {
|
||||
["@parameter.outer"] = "v", -- charwise
|
||||
["@function.outer"] = "V", -- linewise
|
||||
},
|
||||
include_surrounding_whitespace = false,
|
||||
},
|
||||
})
|
||||
|
||||
-- keymaps
|
||||
vim.keymap.set({ "x", "o" }, "am", function()
|
||||
require("nvim-treesitter-textobjects.select").select_textobject("@function.outer", "textobjects")
|
||||
end)
|
||||
vim.keymap.set({ "x", "o" }, "im", function()
|
||||
require("nvim-treesitter-textobjects.select").select_textobject("@function.inner", "textobjects")
|
||||
end)
|
||||
vim.keymap.set({ "x", "o" }, "ac", function()
|
||||
require("nvim-treesitter-textobjects.select").select_textobject("@class.outer", "textobjects")
|
||||
end)
|
||||
vim.keymap.set({ "x", "o" }, "ic", function()
|
||||
require("nvim-treesitter-textobjects.select").select_textobject("@class.inner", "textobjects")
|
||||
end)
|
||||
-- You can also use captures from other query groups like `locals.scm`
|
||||
vim.keymap.set({ "x", "o" }, "as", function()
|
||||
require("nvim-treesitter-textobjects.select").select_textobject("@local.scope", "locals")
|
||||
end)
|
||||
|
||||
-- NOTE: for more textobjects options, see the following link.
|
||||
-- This template is using the new `main` branch of the repo.
|
||||
-- https://github.com/nvim-treesitter/nvim-treesitter-textobjects/tree/main
|
||||
end,
|
||||
},
|
||||
}
|
||||
214
homes/modules/vim/nixcats.nix
Normal file
214
homes/modules/vim/nixcats.nix
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
inputs,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
utils = inputs.nixcats.utils;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
inputs.nixcats.homeModule
|
||||
];
|
||||
|
||||
config = {
|
||||
# this value, nixCats is the defaultPackageName you pass to mkNixosModules
|
||||
# it will be the namespace for your options.
|
||||
nixCats = {
|
||||
enable = true;
|
||||
nixpkgs_version = inputs.nixpkgs;
|
||||
# this will add the overlays from ./overlays and also,
|
||||
# add any plugins in inputs named "plugins-pluginName" to pkgs.neovimPlugins
|
||||
# It will not apply to overall system, just nixCats.
|
||||
addOverlays = # (import ./overlays inputs) ++
|
||||
[
|
||||
(utils.standardPluginOverlay inputs)
|
||||
];
|
||||
# see the packageDefinitions below.
|
||||
# This says which of those to install.
|
||||
packageNames = [ "deavim" ];
|
||||
|
||||
luaPath = "${./.}";
|
||||
|
||||
# the .replace vs .merge options are for modules based on existing configurations,
|
||||
# they refer to how multiple categoryDefinitions get merged together by the module.
|
||||
# for useage of this section, refer to :h nixCats.flake.outputs.categories
|
||||
categoryDefinitions.replace = (
|
||||
{
|
||||
pkgs,
|
||||
settings,
|
||||
categories,
|
||||
extra,
|
||||
name,
|
||||
mkNvimPlugin,
|
||||
...
|
||||
}@packageDef:
|
||||
{
|
||||
lspsAndRuntimeDeps = {
|
||||
general = with pkgs; [
|
||||
ripgrep
|
||||
fd
|
||||
];
|
||||
treesitter = with pkgs; [
|
||||
tree-sitter
|
||||
];
|
||||
lang = with pkgs; {
|
||||
lua = [
|
||||
lua-language-server
|
||||
stylua
|
||||
];
|
||||
nix = [
|
||||
nil
|
||||
nix-doc
|
||||
nixfmt
|
||||
];
|
||||
rust = with pkgs; [
|
||||
cargo
|
||||
rust-analyzer
|
||||
rustfmt
|
||||
];
|
||||
haskell = with pkgs; [
|
||||
haskell-language-server
|
||||
ormolu
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
startupPlugins = {
|
||||
general = with pkgs.vimPlugins; [
|
||||
lze
|
||||
plenary-nvim
|
||||
nvim-notify
|
||||
nvim-web-devicons
|
||||
base16-nvim
|
||||
mini-nvim
|
||||
|
||||
(pkgs.vimUtils.buildVimPlugin {
|
||||
pname = "candyland-nvim";
|
||||
version = "1.0";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "AmberLehmann";
|
||||
repo = "candyland.nvim";
|
||||
rev = "neovim-colorscheme";
|
||||
hash = "sha256-KEHMnpyJOhdF8ZPWuKF3uP7UX5fnzE31LMe+XxHK+i8=";
|
||||
};
|
||||
})
|
||||
];
|
||||
treesitter = with pkgs.vimPlugins; [
|
||||
nvim-treesitter-textobjects
|
||||
nvim-treesitter.withAllGrammars
|
||||
];
|
||||
};
|
||||
optionalPlugins = with pkgs.vimPlugins; {
|
||||
general = [
|
||||
orgmode
|
||||
];
|
||||
ui = [
|
||||
dressing-nvim
|
||||
];
|
||||
qol = [
|
||||
undotree
|
||||
mini-hipatterns
|
||||
];
|
||||
telescope = [
|
||||
telescope-nvim
|
||||
telescope-fzf-native-nvim
|
||||
telescope-ui-select-nvim
|
||||
];
|
||||
fyler = [
|
||||
fyler-nvim
|
||||
];
|
||||
lsp = [
|
||||
nvim-lspconfig
|
||||
];
|
||||
completion = [
|
||||
blink-cmp
|
||||
nvim-cmp
|
||||
luasnip
|
||||
friendly-snippets
|
||||
cmp_luasnip
|
||||
cmp-buffer
|
||||
cmp-path
|
||||
cmp-nvim-lua
|
||||
cmp-nvim-lsp
|
||||
cmp-cmdline
|
||||
cmp-nvim-lsp-signature-help
|
||||
cmp-cmdline-history
|
||||
lspkind-nvim
|
||||
];
|
||||
format = [
|
||||
conform-nvim
|
||||
];
|
||||
comment = [
|
||||
comment-nvim
|
||||
];
|
||||
lang = {
|
||||
};
|
||||
};
|
||||
|
||||
# shared libraries to be added to LD_LIBRARY_PATH
|
||||
# variable available to nvim runtime
|
||||
sharedLibraries = {
|
||||
general = with pkgs; [
|
||||
# libgit2
|
||||
];
|
||||
};
|
||||
environmentVariables = {
|
||||
lang = {
|
||||
rust = {
|
||||
# it literally won't see the rust-analyzer provided to it
|
||||
# if you don't use an envrionment variable to tell it
|
||||
RUST_ANALYZER_CMD = "${pkgs.rust-analyzer}/bin/rust-analyzer";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
# see :help nixCats.flake.outputs.packageDefinitions
|
||||
packageDefinitions.replace = {
|
||||
# these are the names of your packages
|
||||
# you can include as many as you wish.
|
||||
deavim =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
# they contain a settings set defined above
|
||||
# see :help nixCats.flake.outputs.settings
|
||||
settings = {
|
||||
wrapRc = true;
|
||||
# IMPORTANT:
|
||||
# your alias may not conflict with your other packages.
|
||||
aliases = [
|
||||
"dvim"
|
||||
];
|
||||
};
|
||||
# and a set of categories that you want
|
||||
# (and other information to pass to lua)
|
||||
categories = {
|
||||
general = true;
|
||||
|
||||
ui = true;
|
||||
qol = true;
|
||||
telescope = true;
|
||||
fyler = true;
|
||||
lsp = true;
|
||||
completion = true;
|
||||
format = true;
|
||||
comment = true;
|
||||
treesitter = true;
|
||||
|
||||
lang = {
|
||||
lua = true;
|
||||
nix = true;
|
||||
rust = true;
|
||||
haskell = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue