1
Fork 0
satellite/home/adrielus/features/neovim/default.nix

110 lines
3 KiB
Nix
Raw Normal View History

2023-01-10 02:38:06 +01:00
{ pkgs, lib, config, paths, ... }:
let
2023-01-22 01:22:38 +01:00
devMode = true;
2023-01-10 02:38:06 +01:00
extraPackages = with pkgs; [
# Language servers
nodePackages.typescript-language-server # typescript
nodePackages_latest.purescript-language-server # purescript
sumneko-lua-language-server # lua
rnix-lsp # nix
haskell-language-server # haskell
tectonic # something related to latex (?)
texlab # latex
nodePackages_latest.vscode-langservers-extracted
# Formatters
luaformatter # Lua
stylua # Lua
ormolu # Haskell
nodePackages_latest.purs-tidy # Purescript
nodePackages_latest.prettier # Js & friends
2023-01-10 02:38:06 +01:00
nodePackages_latest.prettier_d_slim # Js & friends
# Others
nodePackages.typescript # typescript
wakatime # time tracking
fd # file finder
ripgrep # Grep rewrite
update-nix-fetchgit # Useful for nix stuff
tree-sitter # Syntax highlighting
libstdcxx5 # Required by treesitter aparently
zathura # Pdf reader
xdotool # For zathura reverse search or whatever it's called
lua # For repls and whatnot
glow #Mmd preview in terminal
pandoc # Md processing
libsForQt5.falkon # Aparently needed for md preview
texlive.combined.scheme-full # Latex stuff
python38Packages.pygments # required for latex syntax highlighting
];
in
let
symlink = config.lib.file.mkOutOfStoreSymlink;
2023-01-10 02:38:06 +01:00
2023-01-22 01:22:38 +01:00
extraRuntime = env: [
# Snippets
2023-01-10 02:38:06 +01:00
(if devMode
then symlink "${paths.dotfiles}/vscode-snippets"
else ../../../../dotfiles/vscode-snippets)
2023-01-22 01:22:38 +01:00
# Base16 theme
(pkgs.writeTextDir
"lua/nix/theme.lua"
''
return {
name = "${config.scheme.scheme}"
}
'')
# Provide hints as to what app we are in
# (Useful because neovide does not provide the info itself right away)
(pkgs.writeTextDir
"lua/nix/env.lua"
"return '${env}'"
)
2023-01-10 02:38:06 +01:00
];
# Wraps a neovim client, providing the dependencies
# and setting some flags:
#
# - NVIM_EXTRA_RUNTIME provides extra directories to add to the runtimepath.
# I cannot just install those dirs using the builtin package support because
# my package manager (lazy.nvim) disables those.
wrapClient = { base, name, extraArgs ? "" }:
2023-01-10 02:38:06 +01:00
pkgs.symlinkJoin {
inherit (base) name meta;
paths = [ base ];
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/${name} \
--prefix PATH : ${lib.makeBinPath extraPackages} \
2023-01-22 01:22:38 +01:00
--set NVIM_EXTRA_RUNTIME ${lib.strings.concatStringsSep "," (extraRuntime name)} \
${extraArgs}
2023-01-10 02:38:06 +01:00
'';
};
neovim = wrapClient { base = pkgs.neovim-nightly; name = "nvim"; };
neovide = wrapClient {
base = pkgs.neovide;
name = "neovide";
extraArgs = "--set NEOVIDE_MULTIGRID true";
};
2023-01-10 02:38:06 +01:00
in
{
# Do not manage neovim via nix
programs.neovim.enable = false;
home.file.".config/nvim".source =
if devMode then
symlink "${paths.dotfiles}/neovim" else
2023-01-10 02:38:06 +01:00
../../../../dotfiles/neovim;
home.sessionVariables.EDITOR = "nvim";
2023-01-10 02:38:06 +01:00
home.packages = [
neovim
neovide
];
}