neovim.nix 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. { lib
  2. , stdenv
  3. , writeTextFile
  4. , neovim
  5. , neovim-unwrapped
  6. , fd
  7. , ripgrep
  8. , nodePackages
  9. , vimPlugins
  10. , vimUtils
  11. , fetchFromGitHub
  12. , withPlayground ? false
  13. }:
  14. let
  15. buildNeovimPlugin = attrs: stdenv.mkDerivation ({
  16. forceShare= [ "man" "info" ];
  17. installPhase = ''
  18. cp -r . $out
  19. if [ -d "$out/doc" ]; then
  20. ${neovim-unwrapped}/bin/nvim -N -u NONE -i NONE -n -E -s -V1 -c "helptags $out/doc" +quit!
  21. fi
  22. '';
  23. } // attrs);
  24. plugins = import ./plugins.nix { inherit buildNeovimPlugin fetchFromGitHub; };
  25. extra-treesitter-textobjects = writeTextFile {
  26. name = "extra-treesitter-textobjects";
  27. destination = "/after/queries/javascript/textobjects.scm";
  28. text = ''
  29. ; support swapping elements inside arrays too
  30. (array "," . (_) @parameter.inner)
  31. (array . (_) @parameter.inner ",")
  32. '';
  33. };
  34. extraPath = [
  35. fd
  36. ripgrep
  37. nodePackages.typescript-language-server
  38. nodePackages.eslint_d
  39. ];
  40. in
  41. neovim.override {
  42. extraMakeWrapperArgs = "--prefix PATH : ${lib.makeBinPath extraPath}";
  43. configure = {
  44. customRC = ''
  45. source ${./settings.lua}
  46. source ${./plugins.lua}
  47. source ${./mappings.lua}
  48. source ${./autocmd.lua}
  49. source ${./lsp.lua}
  50. source ${./theme.lua}
  51. '' + lib.optionalString withPlayground ''
  52. source ${./playground.lua}
  53. '';
  54. packages.myVimPackage = with vimPlugins; {
  55. start = plugins ++ [
  56. (nvim-treesitter.withPlugins (p: with p; [
  57. tree-sitter-bash
  58. tree-sitter-css
  59. tree-sitter-go
  60. tree-sitter-javascript
  61. tree-sitter-json
  62. tree-sitter-lua
  63. tree-sitter-nix
  64. tree-sitter-ruby
  65. tree-sitter-tsx
  66. tree-sitter-typescript
  67. ] ++ lib.optionals withPlayground [
  68. tree-sitter-query
  69. ]))
  70. extra-treesitter-textobjects
  71. ] ++ lib.optionals withPlayground [
  72. playground
  73. ];
  74. };
  75. };
  76. }