add some more hints on the default settings for neovim; just go with alejandra formatter; add more docs on qa

std
Hung 2023-06-17 20:32:15 -07:00
parent e7efe1a965
commit 6352f821c3
13 changed files with 296 additions and 210 deletions

View File

@ -0,0 +1,12 @@
# Neovim: Testing cmp for color with Tailwind
- [ ] It should detect a project uses tailwind, maybe via some kind of config file
(`tailwind.config.{cjs,mjs,js,ts,json,tsx,toml,yaml}`), or just based on the
string content or via tree-stiter. Check this by `:LspInfo` and `tailwindcss-lsp`
should attach to the current buffer that has tailwind-css string
- [ ] Type in a classname `text-red-500`, just stop at somewhere and start
browsing the cmp-lsp window. It should show a color in place of `lspkind`.
This validates `tailwindcss-colorizer-cmp.nvim` is good
- [ ] Hit that autocomplete, the string should show the color red. This validates
`nvim-colorizer.lua` is properly setup.

View File

@ -104,7 +104,7 @@ WPlug('kyazdani42/nvim-web-devicons') -- icons for folder and filetype
WPlug('m-demare/hlargs.nvim') -- highlights arguments; great for func prog WPlug('m-demare/hlargs.nvim') -- highlights arguments; great for func prog
WPlug('folke/todo-comments.nvim') -- Highlights TODO WPlug('folke/todo-comments.nvim') -- Highlights TODO
WPlug('NvChad/nvim-colorizer.lua') -- color highlighter with tailwind support WPlug('NvChad/nvim-colorizer.lua') -- color highlighter with tailwind support
WPlug('roobert/tailwindcss-colorizer-cmp.nvim') -- color highlighter with tailwind support WPlug('roobert/tailwindcss-colorizer-cmp.nvim') -- color for tailiwnd for compe
-- other utilities -- other utilities
WPlug('nvim-treesitter/nvim-treesitter-context') -- Top one-liner context of func/class scope WPlug('nvim-treesitter/nvim-treesitter-context') -- Top one-liner context of func/class scope
@ -112,6 +112,7 @@ WPlug('nvim-treesitter/playground') -- Sees Treesitter AST - less h
WPlug('saadparwaiz1/cmp_luasnip') -- snippet engine WPlug('saadparwaiz1/cmp_luasnip') -- snippet engine
WPlug('L3MON4D3/LuaSnip') -- snippet engine WPlug('L3MON4D3/LuaSnip') -- snippet engine
WPlug('mickael-menu/zk-nvim') -- Zettelkasten WPlug('mickael-menu/zk-nvim') -- Zettelkasten
WPlug('folke/neodev.nvim') -- Neovim + lua development setup
-- Switch cases: -- Switch cases:
-- `gsp` -> PascalCase (classes), `gsc` -> camelCase (Java), `gs_` -> snake_case (C/C++/Rust) -- `gsp` -> PascalCase (classes), `gsc` -> camelCase (Java), `gs_` -> snake_case (C/C++/Rust)
-- `gsu` -> UPPER_CASE (CONSTs), `gsk` -> kebab-case (Clojure), `gsK` -> Title-Kebab-Case -- `gsu` -> UPPER_CASE (CONSTs), `gsk` -> kebab-case (Clojure), `gsK` -> Title-Kebab-Case
@ -241,7 +242,57 @@ colorscheme gruvbox
]]) ]])
require('hlargs').setup() require('hlargs').setup()
require('nvim-web-devicons').setup() require('nvim-web-devicons').setup()
require('trouble').setup() require('trouble').setup {
position = "bottom", -- position of the list can be: bottom, top, left, right
height = 10, -- height of the trouble list when position is top or bottom
width = 50, -- width of the list when position is left or right
icons = true, -- use devicons for filenames
mode = "workspace_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist"
severity = nil, -- nil (ALL) or vim.diagnostic.severity.ERROR | WARN | INFO | HINT
fold_open = "", -- icon used for open folds
fold_closed = "", -- icon used for closed folds
group = true, -- group results by file
padding = true, -- add an extra new line on top of the list
action_keys = {
-- key mappings for actions in the trouble list
-- map to {} to remove a mapping, for example:
-- close = {},
close = "q", -- close the list
cancel = "<esc>", -- cancel the preview and get back to your last window / buffer / cursor
refresh = "r", -- manually refresh
jump = { "<cr>", "<tab>" }, -- jump to the diagnostic or open / close folds
open_split = { "<c-x>" }, -- open buffer in new split
open_vsplit = { "<c-v>" }, -- open buffer in new vsplit
open_tab = { "<c-t>" }, -- open buffer in new tab
jump_close = { "o" }, -- jump to the diagnostic and close the list
toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode
switch_severity = "s", -- switch "diagnostics" severity filter level to HINT / INFO / WARN / ERROR
toggle_preview = "P", -- toggle auto_preview
hover = "K", -- opens a small popup with the full multiline message
preview = "p", -- preview the diagnostic location
close_folds = { "zM", "zm" }, -- close all folds
open_folds = { "zR", "zr" }, -- open all folds
toggle_fold = { "zA", "za" }, -- toggle fold of current file
previous = "k", -- previous item
next = "j" -- next item
},
indent_lines = true, -- add an indent guide below the fold icons
auto_open = false, -- automatically open the list when you have diagnostics
auto_close = false, -- automatically close the list when you have no diagnostics
auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window
auto_fold = false, -- automatically fold a file trouble list at creation
auto_jump = { "lsp_definitions" }, -- for the given modes, automatically jump if there is only a single result
signs = {
-- icons / text used for a diagnostic
error = "",
warning = "",
hint = "",
information = "",
other = "",
},
use_diagnostic_signs = false -- enabling this will use the signs defined in your lsp client
}
-- TODO: Any way to collect all the TODOs and its variants? -- TODO: Any way to collect all the TODOs and its variants?
require('todo-comments').setup() require('todo-comments').setup()
@ -922,10 +973,10 @@ require('mason-lspconfig').setup_handlers({
defaultConfig = { defaultConfig = {
indent_style = "space", indent_style = "space",
indent_size = 4, indent_size = 4,
} },
} },
} },
} },
} }
end, end,
["pyright"] = function() ["pyright"] = function()
@ -1002,7 +1053,7 @@ require('mason-lspconfig').setup_handlers({
settings = { settings = {
["nil"] = { ["nil"] = {
formatting = { formatting = {
command = {"nix", "run", "nixpkgs#alejandra"}, command = { "nix", "run", "nixpkgs#alejandra" },
}, },
nix = { nix = {
flake = { flake = {

View File

@ -4,11 +4,14 @@
# Additional configurations goes to profiles/<user> # Additional configurations goes to profiles/<user>
# or inlined in flake.nix # or inlined in flake.nix
{ {
config, # Represents the realized final configuration config,
pkgs, # This is by default just ``= import <nixpkgs>{}` # Represents the realized final configuration
pkgs,
# This is by default just ``= import <nixpkgs>{}`
myHome, myHome,
myLib, myLib,
option, # The options we're given, this might be useful for typesafety? option,
# The options we're given, this might be useful for typesafety?
proj_root, proj_root,
... ...
}: let }: let

View File

@ -9,7 +9,8 @@
pkgs.callPackage pkgs.callPackage
({runCommand}: ({runCommand}:
# runCommand source: https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/trivial-builders.nix#L33 # runCommand source: https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/trivial-builders.nix#L33
runCommand outputPath { runCommand outputPath
{
inherit yamlContent; inherit yamlContent;
nativeBuildInputs = [pkgs.yq]; nativeBuildInputs = [pkgs.yq];
} }

View File

@ -3,7 +3,8 @@
{ {
pkgs, pkgs,
lib, lib,
naersk, # rust packages naersk,
# rust packages
... ...
} @ pkgs_input: { } @ pkgs_input: {
# dot-hwtr = import "./dot-hwtr" pkgs_input; # dot-hwtr = import "./dot-hwtr" pkgs_input;

View File

@ -4,9 +4,11 @@
lib, lib,
... ...
}: }:
with builtins; with lib; let with builtins;
with lib; let
pkgs2storeContents = l: pkgs2storeContents = l:
map (x: { map
(x: {
object = x; object = x;
symlink = "none"; symlink = "none";
}) })

View File

@ -4,7 +4,8 @@
config, config,
... ...
}: }:
with builtins; with lib; { with builtins;
with lib; {
imports = [ imports = [
(mkRenamedOptionModule ["wsl" "compatibility" "interopPreserveArgvZero"] ["wsl" "interop" "preserveArgvZero"]) (mkRenamedOptionModule ["wsl" "compatibility" "interopPreserveArgvZero"] ["wsl" "interop" "preserveArgvZero"])
]; ];

View File

@ -4,7 +4,8 @@
config, config,
... ...
}: }:
with builtins; with lib; { with builtins;
with lib; {
options.wsl = with types; let options.wsl = with types; let
coercedToStr = coercedTo (oneOf [bool path int]) toString str; coercedToStr = coercedTo (oneOf [bool path int]) toString str;
in { in {

View File

@ -2,5 +2,4 @@
inputs, inputs,
cell, cell,
}: let }: let
in { in {}
}

View File

@ -1,5 +1,4 @@
{ {
inputs, inputs,
cell, cell,
}: { }: {}
}

View File

@ -1,188 +1,200 @@
# This is an interface for home-profiles and should not contain opinionated # This is an interface for home-profiles and should not contain opinionated
# configurations. It should provide alternative configurations, aggregates # configurations. It should provide alternative configurations, aggregates
# or new configurations # or new configurations
_imports@{inputs, cell}: let _imports@{ inputs, cell }:
let
namespace = "repo"; namespace = "repo";
imports = _imports // {inherit namespace;}; imports = _imports // { inherit namespace; };
in { in
git = { config , lib , ... }: let {
cfg = config."${namespace}".git; git = { config, lib, ... }:
baseAliases = { let
a = "add"; cfg = config."${namespace}".git;
c = "commit"; baseAliases = {
ca = "commit --amend"; a = "add";
cm = "commit -m"; c = "commit";
lol = "log --graph --decorate --pretty=oneline --abbrev-commit"; ca = "commit --amend";
lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all"; cm = "commit -m";
sts = "status"; lol = "log --graph --decorate --pretty=oneline --abbrev-commit";
co = "checkout"; lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all";
b = "branch"; sts = "status";
}; co = "checkout";
default-user = "Pegasust"; b = "branch";
default-email = "pegasucksgg@gmail.com";
in {
options."${namespace}".git = {
aliases = lib.mkOption {
type = lib.types.attrs;
default = { };
example = baseAliases;
description = ''
Additional git aliases. This settings comes with base configuration.
Redeclaring the base config will override the values.
''; # TODO: Add baseAliases as string here (builtins.toString doesn't work)
}; };
name = lib.mkOption { default-user = "Pegasust";
type = lib.types.str; default-email = "pegasucksgg@gmail.com";
default = default-user; in
description = "Git username that appears on commits"; {
example = default-user; options."${namespace}".git = {
aliases = lib.mkOption {
type = lib.types.attrs;
default = { };
example = baseAliases;
description = ''
Additional git aliases. This settings comes with base configuration.
Redeclaring the base config will override the values.
''; # TODO: Add baseAliases as string here (builtins.toString doesn't work)
};
name = lib.mkOption {
type = lib.types.str;
default = default-user;
description = "Git username that appears on commits";
example = default-user;
};
email = lib.mkOption {
type = lib.types.str;
default = default-email;
example = default-email;
description = "Git email that appears on commits";
};
ignores = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [
".vscode" # vscode settings
".direnv" # .envrc cached outputs
".DS_Store" # MacOS users, amrite
];
description = ''
.gitignore patterns that are applied in every "${namespace}"sitory.
This is useful for IDE-specific settings.
'';
example = [ ".direnv" "node_modules" ];
};
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Enables git
'';
example = false;
};
credentialCacheTimeoutSeconds = lib.mkOption {
type = lib.types.int;
default = 3000;
description = "Credential cache (in-memory store) for Git in seconds.";
example = 3000;
};
}; };
email = lib.mkOption { # TODO : anyway to override configuration?
type = lib.types.str; # idk wtf I was thinking about. there is no context in this question
default = default-email; config.programs.git = {
example = default-email; inherit (cfg) enable ignores;
description = "Git email that appears on commits"; userName = cfg.name;
}; userEmail = cfg.email;
ignores = lib.mkOption { aliases = baseAliases // cfg.aliases;
type = lib.types.listOf lib.types.str; extraConfig = {
default = [ # TODO: in the case of darwin, git always open up the built-in keychain.
".vscode" # vscode settings # possibly something we can't really control since we don't have access to `nix-darwin`
".direnv" # .envrc cached outputs credential.helper = "cache --timeout=${builtins.toString cfg.credentialCacheTimeoutSeconds}";
".DS_Store" # MacOS users, amrite };
]; lfs.enable = true;
description = ''
.gitignore patterns that are applied in every "${namespace}"sitory.
This is useful for IDE-specific settings.
'';
example = [ ".direnv" "node_modules" ];
};
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Enables git
'';
example = false;
};
credentialCacheTimeoutSeconds = lib.mkOption {
type = lib.types.int;
default = 3000;
description = "Credential cache (in-memory store) for Git in seconds.";
example = 3000;
}; };
}; };
# TODO : anyway to override configuration?
# idk wtf I was thinking about. there is no context in this question
config.programs.git = {
inherit (cfg) enable ignores;
userName = cfg.name;
userEmail = cfg.email;
aliases = baseAliases // cfg.aliases;
extraConfig = {
# TODO: in the case of darwin, git always open up the built-in keychain.
# possibly something we can't really control since we don't have access to `nix-darwin`
credential.helper = "cache --timeout=${builtins.toString cfg.credentialCacheTimeoutSeconds}";
};
lfs.enable = true;
};
};
alacritty = {config, lib}: let alacritty = { config, lib }:
inherit (inputs.cells.repo.lib) fromYAML; let
cfg = config."${namespace}".alacritty; inherit (inputs.cells.repo.lib) fromYAML;
in { cfg = config."${namespace}".alacritty;
options."${namespace}".alacritty = { in
font.family = lib.mkOption { {
type = lib.types.nullOr lib.types.singleLineStr; options."${namespace}".alacritty = {
default = null; font.family = lib.mkOption {
description = '' type = lib.types.nullOr lib.types.singleLineStr;
The font family for Alacritty default = null;
''; description = ''
example = "DroidSansMono NF"; The font family for Alacritty
'';
example = "DroidSansMono NF";
};
font.size = lib.mkOption {
type = lib.types.nullOr lib.types.number;
default = 11.0;
description = ''
The default font size for Alacritty. This is probably measured in px.
'';
example = 7.0;
};
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Enables alacritty
'';
example = true;
};
config-path = lib.mkOption {
type = lib.types.path;
description = "Path to alacritty yaml";
default = null;
example = "./config/alacritty.yaml";
};
}; };
font.size = lib.mkOption { config.programs.alacritty = {
type = lib.types.nullOr lib.types.number; enable = cfg.enable;
default = 11.0; settings =
description = '' let
The default font size for Alacritty. This is probably measured in px. ;
''; actualConfig =
example = 7.0; if cfg.config-path != null then fromYAML (builtins.readFile cfg.config-path) else { };
}; in
enable = lib.mkOption { lib.recursiveUpdate actualConfig {
type = lib.types.bool; font.normal.family = lib.mkIf (font.family != null) font.family;
default = false; font.size = lib.mkIf (font.size != null) font.size;
description = '' };
Enables alacritty
'';
example = true;
};
config-path = lib.mkOption {
type = lib.types.path;
description = "Path to alacritty yaml";
default = null;
example = "./config/alacritty.yaml";
}; };
}; };
config.programs.alacritty = {
enable = cfg.enable;
settings = let ;
actualConfig = if cfg.config-path != null then fromYAML (builtins.readFile cfg.config-path) else {};
in lib.recursiveUpdate actualConfig {
font.normal.family = lib.mkIf (font.family != null) font.family;
font.size = lib.mkIf (font.size != null) font.size;
};
};
};
# TODO: chromium is not really supported on darwin # TODO: chromium is not really supported on darwin
private_chromium = { config, pkgs, lib, ... }: let private_chromium = { config, pkgs, lib, ... }:
cfg = config."${namespace}".private_chromium; let
in { cfg = config."${namespace}".private_chromium;
options."${namespace}".private_chromium = { in
enable = lib.mkOption { {
type = lib.types.bool; options."${namespace}".private_chromium = {
default = true; enable = lib.mkOption {
example = false; type = lib.types.bool;
description = '' default = true;
Enable extremely lightweight chromium with vimium plugin example = false;
''; description = ''
Enable extremely lightweight chromium with vimium plugin
'';
};
}; };
}; config = lib.mkIf (cfg.enable) {
config = lib.mkIf (cfg.enable) { # home.packages = [pkgs.ungoogled-chromium];
# home.packages = [pkgs.ungoogled-chromium]; programs.chromium = {
programs.chromium = { enable = true;
enable = true; package = pkgs.ungoogled-chromium;
package = pkgs.ungoogled-chromium; extensions =
extensions = let
let # TODO: how about a chrome extension registry?
# TODO: how about a chrome extension registry? mkChromiumExtForVersion = browserVersion: { id, sha256, extVersion, ... }:
mkChromiumExtForVersion = browserVersion: { id, sha256, extVersion, ... }: {
{ inherit id;
inherit id; crxPath = builtins.fetchurl {
crxPath = builtins.fetchurl { url = "https://clients2.google.com/service/update2/crx" +
url = "https://clients2.google.com/service/update2/crx" + "?response=redirect" +
"?response=redirect" + "&acceptformat=crx2,crx3" +
"&acceptformat=crx2,crx3" + "&prodversion=${browserVersion}" +
"&prodversion=${browserVersion}" + "&x=id%3D${id}%26installsource%3Dondemand%26uc";
"&x=id%3D${id}%26installsource%3Dondemand%26uc"; name = "${id}.crx";
name = "${id}.crx"; inherit sha256;
inherit sha256; };
version = extVersion;
}; };
version = extVersion; mkChromiumExt = mkChromiumExtForVersion (lib.versions.major pkgs.ungoogled-chromium.version);
}; in
mkChromiumExt = mkChromiumExtForVersion (lib.versions.major pkgs.ungoogled-chromium.version); [
in # vimium
[ (mkChromiumExt {
# vimium id = "dbepggeogbaibhgnhhndojpepiihcmeb";
(mkChromiumExt { sha256 = "00qhbs41gx71q026xaflgwzzridfw1sx3i9yah45cyawv8q7ziic";
id = "dbepggeogbaibhgnhhndojpepiihcmeb"; extVersion = "1.67.4";
sha256 = "00qhbs41gx71q026xaflgwzzridfw1sx3i9yah45cyawv8q7ziic"; })
extVersion = "1.67.4"; ];
}) };
];
}; };
}; };
};
darwin-spotlight = { lib, pkgs, config, ... }: { darwin-spotlight = { lib, pkgs, config, ... }: {
# This patch exists since Darwin's search bar requires solid apps and not # This patch exists since Darwin's search bar requires solid apps and not

View File

@ -1,36 +1,39 @@
{inputs, cell}: let { inputs, cell }:
let
namespace = "repo"; namespace = "repo";
yamlToJsonDrv = pkgs: yamlContent: outputPath: (pkgs.runCommand yamlToJsonDrv = pkgs: yamlContent: outputPath: (pkgs.runCommand
outputPath { inherit yamlContent; nativeBuildInputs = [ pkgs.yq ]; } outputPath
# run yq which outputs '.' (no filter) on file at yamlPath { inherit yamlContent; nativeBuildInputs = [ pkgs.yq ]; }
# note that $out is passed onto the bash/sh script for execution # run yq which outputs '.' (no filter) on file at yamlPath
'' # note that $out is passed onto the bash/sh script for execution
echo "$yamlContent" | yq >$out ''
'') echo "$yamlContent" | yq >$out
'')
{ }); { });
in { in
{
fromYAML = yamlContent: bulitins.fromJSON (builtins.readFile (yamlToJsonDrv inputs.nixpkgs yamlContent "fromYaml.json")); fromYAML = yamlContent: bulitins.fromJSON (builtins.readFile (yamlToJsonDrv inputs.nixpkgs yamlContent "fromYaml.json"));
# NOTE: Deprecate # NOTE: Deprecate
# ctor # ctor
opt-some = a: [a]; opt-some = a: [ a ];
opt-none = []; opt-none = [ ];
opt-none_thunk = _: []; opt-none_thunk = _: [ ];
# from-to null # from-to null
opt-fromNullable = nullable: if nullable == null then [] else [nullable]; opt-fromNullable = nullable: if nullable == null then [ ] else [ nullable ];
opt-toNullable = opt-fork (a:a) (_: null); opt-toNullable = opt-fork (a:a) (_: null);
opt-map = builtins.map; opt-map = builtins.map;
opt-filter = builtins.filter; opt-filter = builtins.filter;
opt-fork = on_some: on_none: opt: if opt == [] then (on_none null) else (on_some (builtins.elemAt opt 0)); opt-fork = on_some: on_none: opt: if opt == [ ] then (on_none null) else (on_some (builtins.elemAt opt 0));
opt-unwrap = opt-fork (a:a) (_: throw "opt-unwrap: expected some, got none"); opt-unwrap = opt-fork (a:a) (_: throw "opt-unwrap: expected some, got none");
opt-unwrapOrElse = opt-fork (a:a); opt-unwrapOrElse = opt-fork (a:a);
opt-unwrapOr = fallback_val: opt-fork (a:a) (_: fallback_val); opt-unwrapOr = fallback_val: opt-fork (a:a) (_: fallback_val);
opt-orElse = opt: fallback_opt: opt-fork (opt-some) (opt-none_thunk) (opt ++ fallback_opt); opt-orElse = opt: fallback_opt: opt-fork (opt-some) (opt-none_thunk) (opt ++ fallback_opt);
opt-leftmostSome = opts: builtins.foldl' (opt-orElse) [] opts; opt-leftmostSome = opts: builtins.foldl' (opt-orElse) [ ] opts;
} }

View File

@ -64,8 +64,7 @@
rev = info.rev; rev = info.rev;
shortRev = builtins.substring 0 7 info.rev; shortRev = builtins.substring 0 7 info.rev;
} }
else { else {}
}
) )
else if info.type == "path" else if info.type == "path"
then { then {
@ -112,11 +111,13 @@
callFlake4 = flakeSrc: locks: let callFlake4 = flakeSrc: locks: let
flake = import (flakeSrc + "/flake.nix"); flake = import (flakeSrc + "/flake.nix");
inputs = builtins.mapAttrs (n: v: inputs =
if v.flake or true builtins.mapAttrs
then callFlake4 (fetchTree (v.locked // v.info)) v.inputs (n: v:
else fetchTree (v.locked // v.info)) if v.flake or true
locks; then callFlake4 (fetchTree (v.locked // v.info)) v.inputs
else fetchTree (v.locked // v.info))
locks;
outputs = flakeSrc // (flake.outputs (inputs // {self = outputs;})); outputs = flakeSrc // (flake.outputs (inputs // {self = outputs;}));
in in