neovim.nix 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. extra-tsc-compiler = writeTextFile {
  35. name = "extra-tsc-compiler";
  36. destination = "/after/compiler/tsc.vim";
  37. text = ''
  38. CompilerSet makeprg=node_modules/.bin/tsc\ --incremental\ --noEmit
  39. '';
  40. };
  41. extraPath = [
  42. fd
  43. ripgrep
  44. nodePackages.typescript-language-server
  45. nodePackages.eslint_d
  46. ];
  47. in
  48. neovim.override {
  49. extraMakeWrapperArgs = "--prefix PATH : ${lib.makeBinPath extraPath}";
  50. configure = {
  51. customRC = ''
  52. source ${./settings.lua}
  53. source ${./plugins.lua}
  54. source ${./mappings.lua}
  55. source ${./autocmd.lua}
  56. source ${./lsp.lua}
  57. source ${./theme.lua}
  58. '' + lib.optionalString withPlayground ''
  59. source ${./playground.lua}
  60. '';
  61. packages.myVimPackage = with vimPlugins; {
  62. start = plugins ++ [
  63. (nvim-treesitter.withPlugins (p: with p; [
  64. tree-sitter-bash
  65. tree-sitter-css
  66. tree-sitter-elvish
  67. tree-sitter-go
  68. tree-sitter-javascript
  69. tree-sitter-json
  70. tree-sitter-lua
  71. tree-sitter-nix
  72. tree-sitter-ruby
  73. tree-sitter-tsx
  74. tree-sitter-typescript
  75. ] ++ lib.optionals withPlayground [
  76. tree-sitter-query
  77. ]))
  78. extra-treesitter-textobjects
  79. extra-tsc-compiler
  80. ] ++ lib.optionals withPlayground [
  81. playground
  82. ];
  83. };
  84. };
  85. }