Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nixvim): add otter, spectre, render-markdown #55

Merged
merged 3 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 46 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
1. [Troubleshooting](5-troubleshooting)
1. [`Write error: disk full;` during `nixos-install`](write-error-disk-full-during-nixos-install)
1. [Impurities](6-impurities)
1. [Currently known impurities](61-currently-known-impurities)
1. [Notes](62-notes)
1. [References](7-references)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (documentation): Update table of contents to reflect new section title

The section '7. References' has been renamed to '7. Resources'. This change should be reflected in the table of contents for consistency.


## 1. About ❄️
Expand Down Expand Up @@ -136,9 +138,23 @@ mount -o remount,size=15G /tmp

## 6. Impurities 💩

- Currently **none**! 🚀🚀
I heavily dislike using the `--impure` flag, which is unfortunately required
in certain use cases, and I go really out of my way to patch stuff and
avoid using it.

## 7. References 📚
### 6.1 Currently known impurities

- **none**! 🚀🚀

### 6.2 Notes

- [shadow-nix](https://github.com/NicolasGuilloux/shadow-nix) and all its
forks rely on impure imports of hashes, so I am maintaining my own fork
[tsandrini/shadow-nix](https://github.com/tsandrini/shadow-nix)
- I was previously using [devenv](https://devenv.sh/), however, it still doesn't
work really well in a pure mode, so switched to a simple devshell instead.

## 7. Resources 📚

The whole nix ecosystem is in its foundations a revolutionary piece of
software and once you get the hang of it you feel like you’ve really
Expand All @@ -164,3 +180,31 @@ manual.org?)
- [Github code search: thanks to how the nix lang works the code search should be of a huge help, included an example](https://github.com/search?q=pkgs.writeShellScriptBin+language%3ANix&type=code&l=Nix)
- [This is where flake-parts finally clicked for me, huge thanks to viperml~~](https://github.com/viperML/dotfiles)
- [dc-tec/nixvim awesome nixvim config that got me started](https://github.com/dc-tec/nixvim/)

## 8. Credits & Special thanks

To reiterate the previous [Resources](7-resources) section, here are also some
explicit shoutouts & thanks to the people from whom I have at some point in time
taken some piece of code or have been inspired from. Huge thanks ❤️

### 8.1 Major help

These are people that are engrained in the nix community and whose work I/we
use on a daily basis. I hope they will hapilly continue to be a part of the
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (documentation): Fix typo: 'hapilly' should be 'happily'

nix community and I thank them for all of their contributions.

[edolstra](https://github.com/edolstra)
-- [grahamc](https://github.com/grahamc)
-- [domenkozar](https://github.com/domenkozar)
-- [Mic92](https://github.com/Mic92)
-- [hlissner](https://github.com/hlissner)
-- [viperML](https://github.com/viperML)
-- [roberth](https://github.com/roberth)
-- [fufexan](https://github.com/fufexan)
-- [NobbZ](https://github.com/NobbZ)
tsandrini marked this conversation as resolved.
Show resolved Hide resolved

### 8.2 Additional help with ideas & code snippets

[balsoft](https://github.com/balsoft)
-- [dc-tec](https://github.com/dc-tec)
-- [notusknot](https://github.com/notusknot/)
8 changes: 7 additions & 1 deletion flake-parts/hosts/jetbundle/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,13 @@
# NOTE for wireguard
networking.wireguard.enable = true;
networking.firewall = {
allowedUDPPorts = [ 51820 ];
allowedUDPPorts = [
51820
4321
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 question (security): Explain the purpose of opening port 4321 in the firewall configuration

Port 4321 has been added to both allowed UDP and TCP ports in the firewall configuration. Could you provide more information about the service or application that requires this port to be open? This change could have security implications, so it's important to understand its necessity.

];
allowedTCPPorts = [
4321
];
};

# If you intend to route all your traffic through the wireguard tunnel, the
Expand Down
5 changes: 5 additions & 0 deletions flake-parts/modules/nixvim/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,15 @@ in
};

plugins_editor_bufferline = importApply ./plugins/editor/bufferline.nix { inherit localFlake; };
plugins_editor_spectre = importApply ./plugins/editor/spectre.nix { inherit localFlake; };
plugins_editor_copilot-lua = importApply ./plugins/editor/copilot-lua.nix { inherit localFlake; };
plugins_editor_neo-tree = importApply ./plugins/editor/neo-tree.nix { inherit localFlake; };
plugins_editor_noice = importApply ./plugins/editor/noice.nix { inherit localFlake; };
plugins_editor_treesitter = importApply ./plugins/editor/treesitter.nix { inherit localFlake; };
plugins_editor_undotree = importApply ./plugins/editor/undotree.nix { inherit localFlake; };
plugins_editor_render-markdown = importApply ./plugins/editor/render-markdown.nix {
inherit localFlake;
};

plugins_cmp_cmp = importApply ./plugins/cmp/cmp.nix { inherit localFlake; };
plugins_cmp_lspkind = importApply ./plugins/cmp/lspkind.nix { inherit localFlake; };
Expand All @@ -68,5 +72,6 @@ in
plugins_lsp_lsp = importApply ./plugins/lsp/lsp.nix { inherit localFlake; };
plugins_lsp_lspsaga = importApply ./plugins/lsp/lspsaga.nix { inherit localFlake; };
plugins_lsp_trouble = importApply ./plugins/lsp/trouble.nix { inherit localFlake; };
plugins_lsp_otter = importApply ./plugins/lsp/otter.nix { inherit localFlake; };
};
}
6 changes: 3 additions & 3 deletions flake-parts/modules/nixvim/neovide.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ in
end

map("n", "<C-=>", function()
neovideScale(0.1)
neovideScale(0.05)
end)

map("n", "<C-->", function()
neovideScale(-0.1)
neovideScale(-0.05)
end)

vim.g.neovide_transparency = 0.92
neovideScale(-0.3)
neovideScale(-0.35)
end
'';
}
Expand Down
33 changes: 32 additions & 1 deletion flake-parts/modules/nixvim/plugins/cmp/cmp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
}:
let
inherit (lib) mkIf mkMerge mkEnableOption;
inherit (localFlake.lib.modules) mkOverrideAtNixvimModuleLevel;
inherit (localFlake.lib.modules) mkOverrideAtNixvimModuleLevel mkOverrideAtNixvimProfileLevel isModuleLoadedAndEnabled;

cfg = config.tensorfiles.nixvim.plugins.cmp.cmp;
_ = mkOverrideAtNixvimModuleLevel;

copilot-lua-check = isModuleLoadedAndEnabled config "tensorfiles.nixvim.plugins.editor.copilot-lua";

get_bufnrs.__raw = ''
function()
local buf_size_limit = 1024 * 1024 -- 1MB size limit
Expand Down Expand Up @@ -53,6 +55,12 @@ in
// {
default = true;
};

copilot-cmp = {
enable = mkEnableOption ''
Enable the copilot-cmp integration.
'' // { default = true; };
};
};

config = mkIf cfg.enable (mkMerge [
Expand Down Expand Up @@ -106,20 +114,23 @@ in
{
name = "nvim_lsp";
priority = 1100;
# group_index = 2;
option = {
inherit get_bufnrs;
};
}
{
name = "nvim_lsp_signature_help";
priority = 1000;
# group_index = 2;
option = {
inherit get_bufnrs;
};
}
{
name = "nvim_lsp_document_symbol";
priority = 1000;
# group_index = 2;
option = {
inherit get_bufnrs;
};
Expand Down Expand Up @@ -181,6 +192,26 @@ in
};
}
# |----------------------------------------------------------------------| #
(mkIf (cfg.copilot-cmp.enable && copilot-lua-check) {
plugins.copilot-lua = {
suggestion.enabled = mkOverrideAtNixvimProfileLevel false;
panel.enabled = mkOverrideAtNixvimProfileLevel false;
};

plugins.cmp.settings = {
sources = [
{
name = "copilot";
priority = 1200;
# group_index = 2;
option = {
inherit get_bufnrs;
};
}
];
};
})
# |----------------------------------------------------------------------| #
]);

meta.maintainers = with localFlake.lib.maintainers; [ tsandrini ];
Expand Down
11 changes: 9 additions & 2 deletions flake-parts/modules/nixvim/plugins/editor/copilot-lua.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,15 @@ in
{
plugins.copilot-lua = {
enable = _ true;
suggestion.autoTrigger = _ true;
copilotNodeCommand = _ "node";
# package = _ patched-copilot-lua;
suggestion = {
enabled = _ true;
autoTrigger = _ true;
};
# filetypes = {
# "*" = true;
# };
# copilotNodeCommand = _ "node";
};
}
# |----------------------------------------------------------------------| #
Expand Down
56 changes: 56 additions & 0 deletions flake-parts/modules/nixvim/plugins/editor/render-markdown.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# --- flake-parts/modules/nixvim/plugins/editor/render-markdown.nix
#
# Author: tsandrini <[email protected]>
# URL: https://github.com/tsandrini/tensorfiles
# License: MIT
#
# 888 .d888 d8b 888
# 888 d88P" Y8P 888
# 888 888 888
# 888888 .d88b. 88888b. .d8888b .d88b. 888d888 888888 888 888 .d88b. .d8888b
# 888 d8P Y8b 888 "88b 88K d88""88b 888P" 888 888 888 d8P Y8b 88K
# 888 88888888 888 888 "Y8888b. 888 888 888 888 888 888 88888888 "Y8888b.
# Y88b. Y8b. 888 888 X88 Y88..88P 888 888 888 888 Y8b. X88
# "Y888 "Y8888 888 888 88888P' "Y88P" 888 888 888 888 "Y8888 88888P'
{ localFlake }:
{
config,
lib,
pkgs,
...
}:
let
inherit (lib)
mkIf
mkMerge
mkEnableOption
;
# inherit (localFlake.lib.modules) mkOverrideAtNixvimModuleLevel;

cfg = config.tensorfiles.nixvim.plugins.editor.render-markdown;
# _ = mkOverrideAtNixvimModuleLevel;

in
{
options.tensorfiles.nixvim.plugins.editor.render-markdown = {
enable = mkEnableOption ''
TODO
'';
};

config = mkIf cfg.enable (mkMerge [
# |----------------------------------------------------------------------| #
{
extraPlugins = with pkgs.vimPlugins; [
render-markdown
];

extraConfigLua = ''
require('render-markdown').setup()
'';
}
# |----------------------------------------------------------------------| #
]);

meta.maintainers = with localFlake.lib.maintainers; [ tsandrini ];
}
72 changes: 72 additions & 0 deletions flake-parts/modules/nixvim/plugins/editor/spectre.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# --- flake-parts/modules/nixvim/plugins/editor/spectre.nix
#
# Author: tsandrini <[email protected]>
# URL: https://github.com/tsandrini/tensorfiles
# License: MIT
#
# 888 .d888 d8b 888
# 888 d88P" Y8P 888
# 888 888 888
# 888888 .d88b. 88888b. .d8888b .d88b. 888d888 888888 888 888 .d88b. .d8888b
# 888 d8P Y8b 888 "88b 88K d88""88b 888P" 888 888 888 d8P Y8b 88K
# 888 88888888 888 888 "Y8888b. 888 888 888 888 888 888 88888888 "Y8888b.
# Y88b. Y8b. 888 888 X88 Y88..88P 888 888 888 888 Y8b. X88
# "Y888 "Y8888 888 888 88888P' "Y88P" 888 888 888 888 "Y8888 88888P'
{ localFlake }:
{
config,
lib,
...
}:
let
inherit (lib)
mkIf
mkMerge
mkEnableOption
;
inherit (localFlake.lib.modules) mkOverrideAtNixvimModuleLevel;

cfg = config.tensorfiles.nixvim.plugins.editor.spectre;
_ = mkOverrideAtNixvimModuleLevel;
in
{
options.tensorfiles.nixvim.plugins.editor.spectre = {
enable = mkEnableOption ''
TODO
'';

withKeymaps =
mkEnableOption ''
Enable the related included keymaps.
''
// {
default = true;
};
};

config = mkIf cfg.enable (mkMerge [
# |----------------------------------------------------------------------| #
{
plugins.spectre = {
enable = _ true;
};
}
# |----------------------------------------------------------------------| #
(mkIf cfg.withKeymaps {
keymaps = [
{
mode = "n";
key = "<leader>R";
action = "<cmd>Spectre<CR>";
options = {
silent = true;
desc = "Search & Replace";
};
}
];
})
# |----------------------------------------------------------------------| #
]);

meta.maintainers = with localFlake.lib.maintainers; [ tsandrini ];
}
Loading
Loading