diff --git a/flake.lock b/flake.lock index 34d672f..d6a3dba 100644 --- a/flake.lock +++ b/flake.lock @@ -416,6 +416,22 @@ "type": "github" } }, + "flake-compat_5": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-outputs": { "inputs": { "flake-parts": "flake-parts_4", @@ -562,6 +578,27 @@ "type": "github" } }, + "flake-parts_8": { + "inputs": { + "nixpkgs-lib": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1706830856, + "narHash": "sha256-a0NYyp+h9hlb7ddVz4LUn1vT/PLwqfrWYcHMvFB1xYg=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "b253292d9c0a5ead9bc98c4e9a26c6312e27d69f", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-root": { "locked": { "lastModified": 1671378805, @@ -698,6 +735,24 @@ } }, "flake-utils_8": { + "inputs": { + "systems": "systems_8" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_9": { "locked": { "lastModified": 1659877975, "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", @@ -729,6 +784,28 @@ "type": "github" } }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "nixvim", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1703887061, + "narHash": "sha256-gGPa9qWNc6eCXT/+Z5/zMkyYOuRZqeFZBDbopNZQkuY=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "43e1aa1308018f37118e34d3a9cb4f5e75dc11d5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "haskell-flake": { "locked": { "lastModified": 1668167720, @@ -783,11 +860,32 @@ ] }, "locked": { - "lastModified": 1704980804, - "narHash": "sha256-lPNNKdPqIYcjhhYIVwlajNt/HqVWbMOoSdNnwCvOP04=", + "lastModified": 1707175763, + "narHash": "sha256-0MKHC6tQ4KEuM5rui6DjKZ/VNiSANB4E+DJ/+wPS1PU=", "owner": "nix-community", "repo": "home-manager", - "rev": "93e804e7f8a1eb88bde6117cd5046501e66aa4bd", + "rev": "f99eace7c167b8a6a0871849493b1c613d0f1b80", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "home-manager_2": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1706955260, + "narHash": "sha256-W3y0j77IDVbmbajudHoUr46RpswujUCl+D5Vru53UsI=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "880d9bc2110f7cae59698f715b8ca42cdc53670c", "type": "github" }, "original": { @@ -843,11 +941,32 @@ ] }, "locked": { - "lastModified": 1704277720, - "narHash": "sha256-meAKNgmh3goankLGWqqpw73pm9IvXjEENJloF0coskE=", + "lastModified": 1706833576, + "narHash": "sha256-w7BL0EWRts+nD1lbLECIuz6fRzmmV+z8oWwoY7womR0=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "0dd382b70c351f528561f71a0a7df82c9d2be9a4", + "rev": "bdbae6ecff8fcc322bf6b9053c0b984912378af7", + "type": "github" + }, + "original": { + "owner": "lnl7", + "repo": "nix-darwin", + "type": "github" + } + }, + "nix-darwin_2": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1706833576, + "narHash": "sha256-w7BL0EWRts+nD1lbLECIuz6fRzmmV+z8oWwoY7womR0=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "bdbae6ecff8fcc322bf6b9053c0b984912378af7", "type": "github" }, "original": { @@ -983,11 +1102,11 @@ }, "nixos-flake": { "locked": { - "lastModified": 1705036214, - "narHash": "sha256-2Kwp646/HV/jzeMX5gG4Asvd8r4gIQ2pRyC4DUcmLFc=", + "lastModified": 1705990839, + "narHash": "sha256-Gb0bvp7BiHBn2PkssT4CiBhD7lVWqSHEBfiai/RFfSQ=", "owner": "srid", "repo": "nixos-flake", - "rev": "f2e467dc34713600b318190580e922f702573881", + "rev": "244072b1f9088833627046d703d7973b90fe7843", "type": "github" }, "original": { @@ -1287,11 +1406,11 @@ }, "nixpkgs_13": { "locked": { - "lastModified": 1705856552, - "narHash": "sha256-JXfnuEf5Yd6bhMs/uvM67/joxYKoysyE3M2k6T3eWbg=", + "lastModified": 1707092692, + "narHash": "sha256-ZbHsm+mGk/izkWtT4xwwqz38fdlwu7nUUKXTOmm4SyE=", "owner": "nixos", "repo": "nixpkgs", - "rev": "612f97239e2cc474c13c9dafa0df378058c5ad8d", + "rev": "faf912b086576fd1a15fca610166c98d47bc667e", "type": "github" }, "original": { @@ -1488,6 +1607,30 @@ "type": "github" } }, + "nixvim": { + "inputs": { + "flake-parts": "flake-parts_8", + "home-manager": "home-manager_2", + "nix-darwin": "nix-darwin_2", + "nixpkgs": [ + "nixpkgs" + ], + "pre-commit-hooks": "pre-commit-hooks" + }, + "locked": { + "lastModified": 1707344886, + "narHash": "sha256-icqj994+jxpkNMP8r6csF3MoEwYzme4CM0rPF4044oM=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "ec07263b1693ebbd74080b1e21d9b88ae7b74d18", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, "nose": { "flake": false, "locked": { @@ -1622,6 +1765,34 @@ "type": "github" } }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat_5", + "flake-utils": "flake-utils_8", + "gitignore": "gitignore", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ], + "nixpkgs-stable": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1706424699, + "narHash": "sha256-Q3RBuOpZNH2eFA1e+IHgZLAOqDD9SKhJ/sszrL8bQD4=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "7c54e08a689b53c8a1e5d70169f2ec9e2a68ffaf", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, "process-compose-flake": { "locked": { "lastModified": 1693927910, @@ -1674,6 +1845,7 @@ "nixos-vscode-server": "nixos-vscode-server", "nixpkgs": "nixpkgs_13", "nixpkgs-match": "nixpkgs-match", + "nixvim": "nixvim", "nuenv": "nuenv_2", "sops-nix": "sops-nix", "treefmt-nix": "treefmt-nix_3", @@ -1768,7 +1940,7 @@ }, "rust-overlay_4": { "inputs": { - "flake-utils": "flake-utils_8", + "flake-utils": "flake-utils_9", "nixpkgs": [ "nuenv", "nixpkgs" @@ -1929,6 +2101,21 @@ "type": "github" } }, + "systems_8": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "treefmt-nix": { "locked": { "lastModified": 1672170030, diff --git a/flake.nix b/flake.nix index c15a447..76c406e 100644 --- a/flake.nix +++ b/flake.nix @@ -33,6 +33,10 @@ actual.url = "github:srid/actual"; actual.inputs.nixpkgs.follows = "nixpkgs"; + # Neovim + nixvim.url = "github:nix-community/nixvim"; + nixvim.inputs.nixpkgs.follows = "nixpkgs"; + # Emacs emacs-overlay.url = "github:nix-community/emacs-overlay"; nix-doom-emacs.url = "github:nix-community/nix-doom-emacs"; diff --git a/home/default.nix b/home/default.nix index 3b9301e..7a0b8a1 100644 --- a/home/default.nix +++ b/home/default.nix @@ -1,10 +1,11 @@ -{ self, ... }: +{ self, inputs, ... }: { flake = { homeModules = { common = { home.stateVersion = "22.11"; imports = [ + inputs.nixvim.homeManagerModules.nixvim ./tmux.nix ./neovim.nix ./helix.nix diff --git a/home/neovim.lua b/home/neovim.lua deleted file mode 100644 index 4efa1ee..0000000 --- a/home/neovim.lua +++ /dev/null @@ -1,35 +0,0 @@ --- ------- --- Library --- ------- - -function map (mode, shortcut, command) -vim.api.nvim_set_keymap(mode, shortcut, command, { noremap = true, silent = true }) -end -function nmap(shortcut, command) -map('n', shortcut, command) -end -function imap(shortcut, command) -map('i', shortcut, command) -end - --- ------ --- Config --- ------ - -vim.cmd([[ -set nobackup -set number -set termguicolors " 24-bit colors -" let g:tokyonight_style = "day" -" let g:tokyonight_italic_functions = 1 -" colorscheme tokyonight -" colorscheme sonokai -colorscheme PaperColor -]]) - --- I don't care about tabs. -vim.opt.tabstop = 2 -vim.opt.shiftwidth = 2 -vim.opt.expandtab = true - - diff --git a/home/neovim.nix b/home/neovim.nix index 92e3d0b..56113b9 100644 --- a/home/neovim.nix +++ b/home/neovim.nix @@ -1,123 +1,23 @@ -{ pkgs, ... }: { - imports = [ - ./neovim/telescope.nix - ./neovim/coc.nix - ./neovim/haskell.nix - ./neovim/rust.nix - ./neovim/zk.nix - # which-key must be the last import for it to recognize the keybindings of - # previous imports. - ./neovim/which-key.nix - ]; - programs.neovim = { + programs.nixvim = { enable = true; - extraPackages = [ - pkgs.lazygit - ]; - - # Full list here, - # https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/vim/plugins/generated.nix - plugins = with pkgs.vimPlugins; [ - # Status bar for vim - - # For working mouse support when running inside tmux - terminus - - { - plugin = lazygit-nvim; - type = "lua"; - config = '' - nmap("gg", ":LazyGit") - ''; - } - - (nvim-treesitter.withPlugins (_: pkgs.tree-sitter.allGrammars)) - # Preferred theme - tokyonight-nvim - sonokai - dracula-vim - gruvbox - papercolor-theme - - # File browser - { - plugin = nvim-tree-lua; - type = "lua"; - config = '' - require("nvim-tree").setup() - ''; - } - nvim-web-devicons - - { - plugin = lualine-nvim; - type = "lua"; - config = '' - require('lualine').setup { - options = { - theme = 'tokyonight' - } - } - ''; - } - - # Buffer tabs - { - plugin = bufferline-nvim; - type = "lua"; - config = '' - require("bufferline").setup{ } - nmap("b", ":BufferLineCycleNext") - nmap("B", ":BufferLineCyclePrev") - ''; - } - - # Developing plugins in Haskell - nvim-hs-vim - - # Language support - vim-nix - - # nushell - null-ls-nvim - { - plugin = nvim-nu; - type = "lua"; - config = '' - require'nu'.setup{ - use_lsp_features = true, -- requires https://github.com/jose-elias-alvarez/null-ls.nvim - -- lsp_feature: all_cmd_names is the source for the cmd name completion. - -- It can be - -- * a string, which is interpreted as a shell command and the returned list is the source for completions (requires plenary.nvim) - -- * a list, which is the direct source for completions (e.G. all_cmd_names = {"echo", "to csv", ...}) - -- * a function, returning a list of strings and the return value is used as the source for completions - all_cmd_names = [[nu -c 'help commands | get name | str join "\n"']] - } - ''; - } - - vim-markdown - ]; - - # Add library code here for use in the Lua config from the - # plugins list above. - extraConfig = '' - lua << EOF - ${builtins.readFile ./neovim.lua} - EOF - ''; + colorschemes.gruvbox.enable = true; + plugins = { + lightline.enable = true; + lsp = { + enable = true; + servers = { + hls.enable = true; + marksman.enable = true; + nil_ls.enable = true; + rust-analyzer = { + enable = true; + installCargo = false; + installRustc = false; + }; + }; + }; + }; }; - - home.packages = [ - (pkgs.writeShellApplication { - name = "ee"; - text = '' - set -x - exec nvim "$(fzf)" - ''; - }) - ]; - } diff --git a/home/neovim/coc.nix b/home/neovim/coc.nix deleted file mode 100644 index ae18bc3..0000000 --- a/home/neovim/coc.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ pkgs, ... }: -{ - programs.neovim = { - coc = { - enable = true; - }; - - extraPackages = [ - pkgs.nodejs # coc requires nodejs - ]; - }; -} diff --git a/home/neovim/haskell.nix b/home/neovim/haskell.nix deleted file mode 100644 index 0393802..0000000 --- a/home/neovim/haskell.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ pkgs, ... }: -{ - programs.neovim = { - coc.settings.languageserver.haskell = { - command = "haskell-language-server-wrapper"; - args = [ "--lsp" ]; - rootPatterns = [ - "*.cabal" - "cabal.project" - "hie.yaml" - ]; - filetypes = [ "haskell" "lhaskell" ]; - }; - - plugins = with pkgs.vimPlugins; [ - { - plugin = haskell-vim; - type = "lua"; - config = '' - vim.cmd([[ - let g:haskell_enable_quantification = 1 " to enable highlighting of `forall` - let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec` - let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc` - let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern` - let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles - let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static` - ]]) - ''; - } - ]; - - }; -} diff --git a/home/neovim/rust.nix b/home/neovim/rust.nix deleted file mode 100644 index 003181e..0000000 --- a/home/neovim/rust.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ pkgs, flake, ... }: -{ - programs.neovim = { - coc.settings.languageserver.rust = { - command = "rust-analyzer"; - args = [ ]; - rootPatterns = [ - "Cargo.lock" - ]; - filetypes = [ "rust" ]; - }; - - plugins = with pkgs.vimPlugins; [ - rust-vim - { - plugin = - (pkgs.vimUtils.buildVimPlugin { - name = "coc-rust-analyzer"; - src = flake.inputs.coc-rust-analyzer; - }); - type = "lua"; - config = '' - ''; - } - ]; - - }; -} diff --git a/home/neovim/telescope.nix b/home/neovim/telescope.nix deleted file mode 100644 index 3355788..0000000 --- a/home/neovim/telescope.nix +++ /dev/null @@ -1,53 +0,0 @@ -{ pkgs, ... }: -{ - programs.neovim = { - plugins = with pkgs.vimPlugins; [ - { - plugin = telescope-nvim; - type = "lua"; - config = '' - nmap("ff", ":Telescope find_files") - nmap("fg", ":Telescope live_grep") - nmap("fb", ":Telescope buffers") - nmap("fh", ":Telescope help_tags") - ''; - } - { - plugin = telescope-zoxide; - type = "lua"; - config = '' - nmap("fz", ":Telescope zoxide list") - ''; - } - { - plugin = telescope-file-browser-nvim; - type = "lua"; - config = '' - -- You don't need to set any of these options. - -- IMPORTANT!: this is only a showcase of how you can set default options! - require("telescope").setup { - extensions = { - file_browser = { - theme = "ivy", - mappings = { - ["i"] = { - -- your custom insert mode mappings - }, - ["n"] = { - -- your custom normal mode mappings - }, - }, - }, - }, - } - -- To get telescope-file-browser loaded and working with telescope, - -- you need to call load_extension, somewhere after setup function: - require("telescope").load_extension "file_browser" - nmap("fb", ":Telescope file_browser path=%:p:h") - nmap("fB", ":Telescope file_browser") - ''; - } - - ]; - }; -} diff --git a/home/neovim/which-key.nix b/home/neovim/which-key.nix deleted file mode 100644 index 680aef2..0000000 --- a/home/neovim/which-key.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ pkgs, ... }: -{ - programs.neovim = { - plugins = with pkgs.vimPlugins; [ - # Doom-emacs like experience - { - plugin = vim-which-key; - type = "lua"; - # TODO: How to port this to Lua? - config = '' - vim.cmd([[ - map - let g:mapleader = "\" - let g:maplocalleader = ',' - nnoremap :WhichKey '' - nnoremap :WhichKey ',' - ]]) - ''; - } - # TODO: Don't know how to configure this correctly - # nvim-whichkey-setup-lua - - - ]; - }; -} diff --git a/home/neovim/zk.nix b/home/neovim/zk.nix deleted file mode 100644 index 8ab671c..0000000 --- a/home/neovim/zk.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ pkgs, flake, ... }: -{ - programs.neovim = { - extraPackages = [ - pkgs.zk - ]; - - plugins = [ - { - plugin = - (pkgs.vimUtils.buildVimPlugin { - name = "zk-nvim"; - src = flake.inputs.zk-nvim; - }); - type = "lua"; - config = '' - require("zk").setup({ - -- can be "telescope", "fzf" or "select" (`vim.ui.select`) - -- it's recommended to use "telescope" or "fzf" - picker = "telescope", - - lsp = { - -- `config` is passed to `vim.lsp.start_client(config)` - config = { - cmd = { "zk", "lsp" }, - name = "zk", - -- on_attach = ... - -- etc, see `:h vim.lsp.start_client()` - }, - - -- automatically attach buffers in a zk notebook that match the given filetypes - auto_attach = { - enabled = true, - filetypes = { "markdown" }, - }, - }, - }) - ''; - } - - ]; - }; -}