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('folke/todo-comments.nvim') -- Highlights TODO
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
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('L3MON4D3/LuaSnip') -- snippet engine
WPlug('mickael-menu/zk-nvim') -- Zettelkasten
WPlug('folke/neodev.nvim') -- Neovim + lua development setup
-- Switch cases:
-- `gsp` -> PascalCase (classes), `gsc` -> camelCase (Java), `gs_` -> snake_case (C/C++/Rust)
-- `gsu` -> UPPER_CASE (CONSTs), `gsk` -> kebab-case (Clojure), `gsK` -> Title-Kebab-Case
@ -241,7 +242,57 @@ colorscheme gruvbox
]])
require('hlargs').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?
require('todo-comments').setup()
@ -922,10 +973,10 @@ require('mason-lspconfig').setup_handlers({
defaultConfig = {
indent_style = "space",
indent_size = 4,
}
}
}
}
},
},
},
},
}
end,
["pyright"] = function()
@ -1002,7 +1053,7 @@ require('mason-lspconfig').setup_handlers({
settings = {
["nil"] = {
formatting = {
command = {"nix", "run", "nixpkgs#alejandra"},
command = { "nix", "run", "nixpkgs#alejandra" },
},
nix = {
flake = {

View File

@ -4,11 +4,14 @@
# Additional configurations goes to profiles/<user>
# or inlined in flake.nix
{
config, # Represents the realized final configuration
pkgs, # This is by default just ``= import <nixpkgs>{}`
config,
# Represents the realized final configuration
pkgs,
# This is by default just ``= import <nixpkgs>{}`
myHome,
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,
...
}: let

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,188 +1,200 @@
# This is an interface for home-profiles and should not contain opinionated
# configurations. It should provide alternative configurations, aggregates
# or new configurations
_imports@{inputs, cell}: let
_imports@{ inputs, cell }:
let
namespace = "repo";
imports = _imports // {inherit namespace;};
in {
git = { config , lib , ... }: let
cfg = config."${namespace}".git;
baseAliases = {
a = "add";
c = "commit";
ca = "commit --amend";
cm = "commit -m";
lol = "log --graph --decorate --pretty=oneline --abbrev-commit";
lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all";
sts = "status";
co = "checkout";
b = "branch";
};
default-user = "Pegasust";
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)
imports = _imports // { inherit namespace; };
in
{
git = { config, lib, ... }:
let
cfg = config."${namespace}".git;
baseAliases = {
a = "add";
c = "commit";
ca = "commit --amend";
cm = "commit -m";
lol = "log --graph --decorate --pretty=oneline --abbrev-commit";
lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all";
sts = "status";
co = "checkout";
b = "branch";
};
name = lib.mkOption {
type = lib.types.str;
default = default-user;
description = "Git username that appears on commits";
example = default-user;
default-user = "Pegasust";
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 {
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 {
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;
# 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;
};
};
# 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
inherit (inputs.cells.repo.lib) fromYAML;
cfg = config."${namespace}".alacritty;
in {
options."${namespace}".alacritty = {
font.family = lib.mkOption {
type = lib.types.nullOr lib.types.singleLineStr;
default = null;
description = ''
The font family for Alacritty
'';
example = "DroidSansMono NF";
alacritty = { config, lib }:
let
inherit (inputs.cells.repo.lib) fromYAML;
cfg = config."${namespace}".alacritty;
in
{
options."${namespace}".alacritty = {
font.family = lib.mkOption {
type = lib.types.nullOr lib.types.singleLineStr;
default = null;
description = ''
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 {
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";
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;
};
};
};
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
private_chromium = { config, pkgs, lib, ... }: let
cfg = config."${namespace}".private_chromium;
in {
options."${namespace}".private_chromium = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
example = false;
description = ''
Enable extremely lightweight chromium with vimium plugin
'';
private_chromium = { config, pkgs, lib, ... }:
let
cfg = config."${namespace}".private_chromium;
in
{
options."${namespace}".private_chromium = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
example = false;
description = ''
Enable extremely lightweight chromium with vimium plugin
'';
};
};
};
config = lib.mkIf (cfg.enable) {
# home.packages = [pkgs.ungoogled-chromium];
programs.chromium = {
enable = true;
package = pkgs.ungoogled-chromium;
extensions =
let
# TODO: how about a chrome extension registry?
mkChromiumExtForVersion = browserVersion: { id, sha256, extVersion, ... }:
{
inherit id;
crxPath = builtins.fetchurl {
url = "https://clients2.google.com/service/update2/crx" +
"?response=redirect" +
"&acceptformat=crx2,crx3" +
"&prodversion=${browserVersion}" +
"&x=id%3D${id}%26installsource%3Dondemand%26uc";
name = "${id}.crx";
inherit sha256;
config = lib.mkIf (cfg.enable) {
# home.packages = [pkgs.ungoogled-chromium];
programs.chromium = {
enable = true;
package = pkgs.ungoogled-chromium;
extensions =
let
# TODO: how about a chrome extension registry?
mkChromiumExtForVersion = browserVersion: { id, sha256, extVersion, ... }:
{
inherit id;
crxPath = builtins.fetchurl {
url = "https://clients2.google.com/service/update2/crx" +
"?response=redirect" +
"&acceptformat=crx2,crx3" +
"&prodversion=${browserVersion}" +
"&x=id%3D${id}%26installsource%3Dondemand%26uc";
name = "${id}.crx";
inherit sha256;
};
version = extVersion;
};
version = extVersion;
};
mkChromiumExt = mkChromiumExtForVersion (lib.versions.major pkgs.ungoogled-chromium.version);
in
[
# vimium
(mkChromiumExt {
id = "dbepggeogbaibhgnhhndojpepiihcmeb";
sha256 = "00qhbs41gx71q026xaflgwzzridfw1sx3i9yah45cyawv8q7ziic";
extVersion = "1.67.4";
})
];
mkChromiumExt = mkChromiumExtForVersion (lib.versions.major pkgs.ungoogled-chromium.version);
in
[
# vimium
(mkChromiumExt {
id = "dbepggeogbaibhgnhhndojpepiihcmeb";
sha256 = "00qhbs41gx71q026xaflgwzzridfw1sx3i9yah45cyawv8q7ziic";
extVersion = "1.67.4";
})
];
};
};
};
};
darwin-spotlight = { lib, pkgs, config, ... }: {
# 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";
yamlToJsonDrv = pkgs: yamlContent: outputPath: (pkgs.runCommand
outputPath { inherit yamlContent; nativeBuildInputs = [ pkgs.yq ]; }
# 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
'')
outputPath
{ inherit yamlContent; nativeBuildInputs = [ pkgs.yq ]; }
# 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
'')
{ });
in {
in
{
fromYAML = yamlContent: bulitins.fromJSON (builtins.readFile (yamlToJsonDrv inputs.nixpkgs yamlContent "fromYaml.json"));
# NOTE: Deprecate
# ctor
opt-some = a: [a];
opt-none = [];
opt-none_thunk = _: [];
opt-some = a: [ a ];
opt-none = [ ];
opt-none_thunk = _: [ ];
# 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-map = builtins.map;
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-unwrapOrElse = opt-fork (a:a);
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-leftmostSome = opts: builtins.foldl' (opt-orElse) [] opts;
opt-leftmostSome = opts: builtins.foldl' (opt-orElse) [ ] opts;
}

View File

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