Skip to content

Commit

Permalink
Merge pull request #55 from tsandrini/updates
Browse files Browse the repository at this point in the history
feat(nixvim): add otter, spectre, render-markdown
  • Loading branch information
tsandrini authored Sep 16, 2024
2 parents bbba669 + 3915c84 commit bce9798
Show file tree
Hide file tree
Showing 14 changed files with 327 additions and 28 deletions.
55 changes: 52 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
1. [Troubleshooting](5-troubleshooting)
1. [`Write error: disk full;` during `nixos-install`](write-error-disk-full-during-nixos-install)
1. [Impurities](6-impurities)
1. [References](7-references)
1. [Currently known impurities](61-currently-known-impurities)
1. [Notes](62-notes)
1. [Resources](7-resources)
1. [Credits & Special thanks](8-credits-special-thanks)
1. [Major help](81-major-help)
1. [Additional help](82-additional-help)

## 1. About ❄️

Expand Down Expand Up @@ -136,9 +141,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 +183,33 @@ 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 happily continue to be a part of the
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)

### 8.2 Additional help

Additional help with certain specific areas, inspiration or 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
];
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
41 changes: 40 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,17 @@
}:
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 +59,16 @@ 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 +122,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 +200,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

0 comments on commit bce9798

Please sign in to comment.