1
0
Fork 0
dotfiles/home/programs/nvim/default.nix

414 lines
11 KiB
Nix
Raw Normal View History

{ pkgs, config, lib, ... }:
2021-12-06 22:35:29 +00:00
2023-05-04 11:10:19 +00:00
let
inherit (pkgs.stdenv) isDarwin;
inherit (lib) optionals;
in
2021-12-06 22:35:29 +00:00
{
programs.neovim = {
enable = true;
2024-06-12 16:00:48 +00:00
package = pkgs.neovim;
2021-12-06 22:35:29 +00:00
2022-12-31 15:26:44 +00:00
defaultEditor = true;
withNodeJs = false;
withRuby = false;
2023-12-10 12:04:11 +00:00
withPython3 = false;
2023-07-21 10:29:50 +00:00
extraLuaPackages = luaPkgs: with luaPkgs; [ jsregexp lua-toml readline ];
2021-12-06 22:35:29 +00:00
extraPackages = with pkgs; [
2024-02-16 12:17:56 +00:00
stdenv.cc
2022-02-03 22:35:52 +00:00
git
2022-05-04 13:02:31 +00:00
nodejs
2021-12-06 22:35:29 +00:00
tree-sitter
2022-06-13 19:58:46 +00:00
fd
2022-02-12 22:13:58 +00:00
ripgrep
universal-ctags
2021-12-06 22:35:29 +00:00
# LSP
2024-06-17 22:02:32 +00:00
bash-language-server
2022-11-27 16:12:49 +00:00
fennel-ls
2024-06-21 07:54:25 +00:00
#lexical
2024-06-25 07:24:27 +00:00
lua-language-server
2024-06-25 14:57:10 +00:00
marksman
2024-03-10 12:55:19 +00:00
nil
2021-12-06 22:35:29 +00:00
nodePackages.dockerfile-language-server-nodejs
2022-05-04 13:02:31 +00:00
nodePackages.svelte-language-server
2021-12-20 17:43:23 +00:00
nodePackages.typescript-language-server
2023-06-24 18:19:50 +00:00
nodePackages.vscode-langservers-extracted
2021-12-06 22:35:29 +00:00
nodePackages.yaml-language-server
2024-03-10 12:55:19 +00:00
#nixd
2021-12-06 22:35:29 +00:00
taplo-lsp
2022-04-24 18:09:54 +00:00
# Diagnostic Tools
2022-11-27 16:12:49 +00:00
checkstyle
deadnix
2023-05-01 21:09:15 +00:00
nodePackages.eslint_d
2023-10-18 17:27:11 +00:00
hadolint
2023-03-27 19:19:01 +00:00
luajitPackages.fennel
2023-11-18 12:45:55 +00:00
nixpkgs-fmt
2021-12-06 22:35:29 +00:00
shellcheck
2021-12-18 23:25:21 +00:00
statix
2023-05-04 11:10:19 +00:00
] ++ optionals isDarwin [
2024-07-03 20:11:48 +00:00
elixir-ls
2023-03-27 19:19:01 +00:00
xcbuild
2021-12-06 22:35:29 +00:00
];
extraLuaConfig = /* lua */ ''
vim.loader.enable()
_G.nvim_treesitter_parser_directory = os.getenv("HOME") .. "/.local/share/nvim/nvim-treesitter_parser"
vim.opt.runtimepath:prepend(_G.nvim_treesitter_parser_directory)
require('nifoc.nix')
require('configuration.init')
'';
2023-03-27 19:19:01 +00:00
plugins =
let
2024-04-22 19:03:19 +00:00
customPlugins = import ./plugins.nix { inherit pkgs lib; };
2023-03-27 19:19:01 +00:00
in
2023-07-16 22:17:50 +00:00
with customPlugins; [
2023-03-27 19:19:01 +00:00
# Utils
popup-nvim
plenary-nvim
2023-03-27 19:19:01 +00:00
nvim-web-devicons
2023-07-14 19:07:55 +00:00
{
plugin = wezterm-nvim;
config = builtins.readFile ../../config/nvim/plugins/wezterm.fnl;
type = "fennel";
}
2023-11-29 14:52:16 +00:00
vim-cool
2023-03-27 19:19:01 +00:00
# Keybindings
{
plugin = yanky-nvim;
config = builtins.readFile ../../config/nvim/plugins/yanky.fnl;
type = "fennel";
}
{
plugin = cutlass-nvim;
config = builtins.readFile ../../config/nvim/plugins/cutlass.fnl;
type = "fennel";
}
{
plugin = substitute-nvim;
config = builtins.readFile ../../config/nvim/plugins/substitute.fnl;
type = "fennel";
}
2023-11-29 14:52:16 +00:00
move-nvim
2023-03-27 19:19:01 +00:00
# Themes
dracula-nvim
# Syntax
{
plugin = nvim-treesitter;
config = builtins.readFile ../../config/nvim/plugins/treesitter.fnl;
type = "fennel";
}
2023-07-16 22:17:50 +00:00
{
plugin = rainbow-delimiters-nvim;
config = builtins.readFile ../../config/nvim/plugins/rainbow-delimiters.fnl;
type = "fennel";
}
2023-11-29 14:52:16 +00:00
{
plugin = todo-comments-nvim;
config = builtins.readFile ../../config/nvim/plugins/todo-comments.fnl;
type = "fennel";
}
2023-03-27 19:19:01 +00:00
# Telescope
{
plugin = telescope-nvim;
config = builtins.readFile ../../config/nvim/plugins/telescope.fnl;
type = "fennel";
}
2024-01-20 23:14:00 +00:00
pkgs.vimPlugins.telescope-zf-native-nvim
2023-03-27 19:19:01 +00:00
telescope-ui-select-nvim
telescope-undo-nvim
# LSP
{
plugin = nvim-lspconfig;
config = builtins.readFile ../../config/nvim/plugins/lsp.fnl;
type = "fennel";
}
nvim-jdtls
2023-11-28 16:09:38 +00:00
schemastore-nvim
2023-10-31 20:24:26 +00:00
lspkind-nvim
2023-03-27 19:19:01 +00:00
{
plugin = nvim-navic;
config = builtins.readFile ../../config/nvim/plugins/navic.fnl;
type = "fennel";
}
{
plugin = vim-illuminate;
config = builtins.readFile ../../config/nvim/plugins/illuminate.fnl;
type = "fennel";
}
2024-06-25 07:24:27 +00:00
{
plugin = otter-nvim;
config = builtins.readFile ../../config/nvim/plugins/otter.fnl;
type = "fennel";
}
2023-03-27 19:19:01 +00:00
# Linter
{
plugin = nvim-lint;
config = builtins.readFile ../../config/nvim/plugins/nvim-lint.fnl;
type = "fennel";
}
2023-10-31 20:24:26 +00:00
# Comments
{
2024-05-21 18:59:48 +00:00
plugin = ts-comments-nvim;
2023-10-31 20:24:26 +00:00
config = builtins.readFile ../../config/nvim/plugins/comment.fnl;
type = "fennel";
}
# Snippets
{
plugin = LuaSnip;
config = builtins.readFile ../../config/nvim/plugins/luasnip.fnl;
type = "fennel";
}
# cmp
{
plugin = nvim-cmp;
config = builtins.readFile ../../config/nvim/plugins/cmp.fnl;
type = "fennel";
}
cmp-nvim-lsp
cmp_luasnip
2023-11-21 21:02:44 +00:00
cmp-async-path
2023-10-31 20:24:26 +00:00
cmp-buffer
cmp-cmdline
cmp-nvim-lsp-document-symbol
2023-03-27 19:19:01 +00:00
# Formatting
2023-07-23 20:40:54 +00:00
2023-03-27 19:19:01 +00:00
{
2023-10-09 13:05:57 +00:00
plugin = conform-nvim;
config = builtins.readFile ../../config/nvim/plugins/formatter.fnl;
2023-03-27 19:19:01 +00:00
type = "fennel";
}
# Pairs
2023-10-31 20:24:26 +00:00
{
plugin = nvim-autopairs;
config = builtins.readFile ../../config/nvim/plugins/autopairs.fnl;
type = "fennel";
}
2023-03-27 19:19:01 +00:00
{
plugin = vim-matchup;
config = builtins.readFile ../../config/nvim/plugins/matchup.fnl;
type = "fennel";
}
2023-10-31 20:24:26 +00:00
# Textobjects
2023-12-12 19:05:42 +00:00
nvim-treesitter-textobjects
2023-10-31 20:24:26 +00:00
{
plugin = nvim-surround;
config = builtins.readFile ../../config/nvim/plugins/surround.fnl;
type = "fennel";
}
2023-03-27 19:19:01 +00:00
# UI
2023-11-20 20:59:18 +00:00
{
plugin = oil-nvim;
config = /* fennel */ ''
(let [oil (require :oil)]
(oil.setup))
'';
type = "fennel";
}
2023-03-27 19:19:01 +00:00
{
plugin = heirline-nvim;
config = builtins.readFile ../../config/nvim/plugins/heirline.fnl;
type = "fennel";
}
{
plugin = indent-blankline-nvim;
config = builtins.readFile ../../config/nvim/plugins/indent_line.fnl;
type = "fennel";
}
{
plugin = virt-column-nvim;
config = /* fennel */ ''
2023-03-27 19:19:01 +00:00
(let [virt-column (require :virt-column)]
(virt-column.setup))
'';
type = "fennel";
}
{
plugin = urlview-nvim;
config = builtins.readFile ../../config/nvim/plugins/urlview.fnl;
type = "fennel";
}
{
plugin = gitsigns-nvim;
config = builtins.readFile ../../config/nvim/plugins/gitsigns.fnl;
type = "fennel";
}
2024-01-02 22:35:15 +00:00
{
plugin = diffview-nvim;
config = builtins.readFile ../../config/nvim/plugins/diffview.fnl;
type = "fennel";
}
2023-12-29 00:50:07 +00:00
2023-10-03 21:10:36 +00:00
{
2023-12-29 00:50:07 +00:00
plugin = neogit;
config = builtins.readFile ../../config/nvim/plugins/neogit.fnl;
2023-10-03 21:10:36 +00:00
type = "fennel";
}
2023-11-29 14:52:16 +00:00
{
2023-12-29 00:50:07 +00:00
plugin = fidget-nvim;
config = builtins.readFile ../../config/nvim/plugins/fidget.fnl;
2023-11-29 14:52:16 +00:00
type = "fennel";
}
2023-12-29 00:26:11 +00:00
{
2023-12-29 00:50:07 +00:00
plugin = which-key-nvim;
config = builtins.readFile ../../config/nvim/plugins/which-key.fnl;
2023-12-29 00:26:11 +00:00
type = "fennel";
}
2023-11-25 12:48:18 +00:00
] ++ optionals isDarwin [
2023-11-27 09:34:41 +00:00
{
plugin = pkgs.vimPlugins.cmp-tabnine;
config = builtins.readFile ../../config/nvim/plugins/cmp_tabnine.fnl;
type = "fennel";
}
2023-07-16 22:17:50 +00:00
];
2021-12-06 22:35:29 +00:00
};
2022-04-05 21:13:56 +00:00
xdg.configFile."nvim" = {
2022-04-15 20:43:51 +00:00
source = pkgs.runCommand "nvim-fennel-files"
2022-04-05 19:57:44 +00:00
{
2023-11-16 23:12:19 +00:00
nativeBuildInputs = with pkgs; [ luajitPackages.fennel ];
2022-04-05 19:57:44 +00:00
} ''
2022-04-05 21:13:56 +00:00
mkdir -p $out/lua/configuration
mkdir -p $out/lua/nifoc/utils
2022-11-27 16:12:49 +00:00
mkdir -p $out/ftplugin
2022-04-05 21:13:56 +00:00
mkdir -p $out/after/ftplugin
2022-04-05 19:57:44 +00:00
2022-04-05 21:13:56 +00:00
config_store_path="${../../config/nvim}"
2022-05-12 19:49:19 +00:00
fennel="fennel --use-bit-lib --compile"
echo "Using fennel command: $fennel"
# Change PWD to config directory
cd "$config_store_path"
2022-04-05 19:57:44 +00:00
2022-04-05 21:13:56 +00:00
# Init
2022-05-12 19:49:19 +00:00
echo "Compiling init.fnl ..."
2022-04-05 21:13:56 +00:00
$fennel "$config_store_path/init.fnl" > "$out/lua/configuration/init.lua"
# Utils
nifoc_store_path="$config_store_path/nifoc"
nifoc_store_fnl="$(find "$nifoc_store_path" -type f -name '*.fnl')"
for fnlfile in $nifoc_store_fnl; do
file_out_path="$(echo "$fnlfile" | sed "s|$nifoc_store_path/||" | sed "s/.fnl$/.lua/")"
2023-10-09 13:05:57 +00:00
echo "Compiling $fnlfile -> $out/lua/nifoc/$file_out_path"
2022-04-05 21:13:56 +00:00
$fennel "$fnlfile" > "$out/lua/nifoc/$file_out_path"
done
2022-11-27 16:12:49 +00:00
# ftplugin
ftplugin_store_path="$config_store_path/ftplugin"
ftplugin_store_fnl="$(find "$ftplugin_store_path" -type f -name '*.fnl')"
for fnlfile in $ftplugin_store_fnl; do
file_out_path="$(echo "$fnlfile" | sed "s|$ftplugin_store_path/||" | sed "s/.fnl$/.lua/")"
2023-10-09 13:05:57 +00:00
echo "Compiling $fnlfile -> $out/ftplugin/$file_out_path"
2022-11-27 16:12:49 +00:00
$fennel "$fnlfile" > "$out/ftplugin/$file_out_path"
done
2022-04-05 21:13:56 +00:00
# After
after_store_path="$config_store_path/after"
after_store_fnl="$(find "$after_store_path" -type f -name '*.fnl')"
2022-04-05 19:57:44 +00:00
2022-04-05 21:13:56 +00:00
for fnlfile in $after_store_fnl; do
file_out_path="$(echo "$fnlfile" | sed "s|$after_store_path/||" | sed "s/.fnl$/.lua/")"
2022-04-05 19:57:44 +00:00
2023-10-09 13:05:57 +00:00
echo "Compiling $fnlfile -> $out/after/$file_out_path"
2022-04-05 21:13:56 +00:00
$fennel "$fnlfile" > "$out/after/$file_out_path"
2022-04-05 19:57:44 +00:00
done
2022-05-12 19:49:19 +00:00
# Plugins
echo "Compiling plugin configuration ..."
{
cat <<EOF
${config.programs.neovim.generatedConfigs.fennel}
nil
EOF
2023-10-09 13:05:57 +00:00
} > "$out/lua/configuration/plugins.fnl"
$fennel "$out/lua/configuration/plugins.fnl" > "$out/lua/configuration/plugins.lua"
rm -f "$out/lua/configuration/plugins.fnl"
2022-05-12 19:49:19 +00:00
# Other
echo "Copying tree-sitter queries ..."
2022-04-05 21:13:56 +00:00
cp -r "$after_store_path/queries" "$out/after/"
'';
2021-12-06 22:35:29 +00:00
recursive = true;
};
2021-12-27 20:24:11 +00:00
2023-10-06 21:47:18 +00:00
home = {
file =
let
nvim-spell-directory = "${config.xdg.configHome}/nvim/spell";
in
{
"${nvim-spell-directory}/de.utf-8.spl".source = builtins.fetchurl {
url = "http://ftp.vim.org/pub/vim/runtime/spell/de.utf-8.spl";
sha256 = "73c7107ea339856cdbe921deb92a45939c4de6eb9c07261da1b9dd19f683a3d1";
};
2023-10-06 21:47:18 +00:00
"${nvim-spell-directory}/de.utf-8.sug".source = builtins.fetchurl {
url = "http://ftp.vim.org/pub/vim/runtime/spell/de.utf-8.sug";
sha256 = "13d0ecf92863d89ef60cd4a8a5eb2a5a13a0e8f9ba8d1c6abe47aba85714a948";
};
};
2023-10-06 21:47:18 +00:00
activation.neovimCache = lib.hm.dag.entryAfter [ "linkGeneration" ] /* bash */ ''
$VERBOSE_ECHO "Resetting loader"
2023-12-13 23:29:09 +00:00
$DRY_RUN_CMD ${lib.getExe config.programs.neovim.finalPackage} -l <(echo "vim.loader.reset()")
2023-10-06 21:47:18 +00:00
'';
2024-02-15 23:14:41 +00:00
activation.neovimTreeSitter = lib.hm.dag.entryAfter [ "writeBoundary" ] /* bash */ ''
$VERBOSE_ECHO "Updating tree-sitter parsers"
$DRY_RUN_CMD ${lib.getExe config.programs.neovim.finalPackage} -c 'TSUpdateSync | q' --headless
'';
2023-10-06 21:47:18 +00:00
};
2021-12-06 22:35:29 +00:00
}