From a0e567229062bb148694d3a1952d4f162e833416 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Sat, 30 Dec 2023 13:04:55 +0100 Subject: [PATCH] Convert Neovim configuration to module --- home-manager/cli/default.nix | 1 - home-manager/cli/neovim/default.nix | 122 ----------------- hosts/luci/home-config.nix | 1 + modules/home-manager/cli/neovim/default.nix | 128 ++++++++++++++++++ .../home-manager}/cli/neovim/files/cmp.lua | 0 .../cli/neovim/files/lspconfig.lua | 0 .../cli/neovim/files/lualine.lua | 0 .../cli/neovim/files/luasnip.lua | 0 .../cli/neovim/files/neotree.lua | 0 .../cli/neovim/files/options.lua | 0 .../cli/neovim/files/treesitter.lua | 0 .../cli/neovim/files/whichkey.lua | 0 modules/home-manager/default.nix | 1 + 13 files changed, 130 insertions(+), 123 deletions(-) delete mode 100644 home-manager/cli/neovim/default.nix create mode 100644 modules/home-manager/cli/neovim/default.nix rename {home-manager => modules/home-manager}/cli/neovim/files/cmp.lua (100%) rename {home-manager => modules/home-manager}/cli/neovim/files/lspconfig.lua (100%) rename {home-manager => modules/home-manager}/cli/neovim/files/lualine.lua (100%) rename {home-manager => modules/home-manager}/cli/neovim/files/luasnip.lua (100%) rename {home-manager => modules/home-manager}/cli/neovim/files/neotree.lua (100%) rename {home-manager => modules/home-manager}/cli/neovim/files/options.lua (100%) rename {home-manager => modules/home-manager}/cli/neovim/files/treesitter.lua (100%) rename {home-manager => modules/home-manager}/cli/neovim/files/whichkey.lua (100%) diff --git a/home-manager/cli/default.nix b/home-manager/cli/default.nix index 1eb4ae3..dc0a3b6 100644 --- a/home-manager/cli/default.nix +++ b/home-manager/cli/default.nix @@ -5,7 +5,6 @@ ./git.nix ./pass.nix ./gnupg.nix - ./neovim ./vifm ./bat.nix ./eza.nix diff --git a/home-manager/cli/neovim/default.nix b/home-manager/cli/neovim/default.nix deleted file mode 100644 index c1eecbe..0000000 --- a/home-manager/cli/neovim/default.nix +++ /dev/null @@ -1,122 +0,0 @@ -{ pkgs, config, ... }: -let - nvim-spell-fr-utf8-dictionary = builtins.fetchurl { - url = "http://ftp.vim.org/vim/runtime/spell/fr.utf-8.spl"; - sha256 = "abfb9702b98d887c175ace58f1ab39733dc08d03b674d914f56344ef86e63b61"; - }; - - nvim-spell-fr-utf8-suggestions = builtins.fetchurl { - url = "http://ftp.vim.org/vim/runtime/spell/fr.utf-8.sug"; - sha256 = "0294bc32b42c90bbb286a89e23ca3773b7ef50eff1ab523b1513d6a25c6b3f58"; - }; -in -{ - home.file."${config.xdg.configHome}/nvim/spell/fr.utf-8.spl".source = nvim-spell-fr-utf8-dictionary; - home.file."${config.xdg.configHome}/nvim/spell/fr.utf-8.sug".source = nvim-spell-fr-utf8-suggestions; - programs.neovim = { - enable = true; - defaultEditor = true; - vimAlias = true; - withNodeJs = true; - withPython3 = true; - extraPackages = with pkgs; [ - # LSP Servers - clang-tools - lua-language-server - marksman - nil - nodePackages.bash-language-server - python3Packages.python-lsp-server - rnix-lsp - shellcheck - - # Formatters - nixfmt - shfmt - ]; - extraLuaConfig = (builtins.readFile ./files/options.lua); - plugins = with pkgs.vimPlugins; [ - { - plugin = nvim-autopairs; - type = "lua"; - config = '' - local autopair = require("nvim-autopairs").setup {} - ''; - } - { - plugin = nvim-base16; - type = "lua"; - config = '' - vim.cmd.colorscheme 'base16-default-dark' - ''; - } - { - plugin = nvim-cmp; - type = "lua"; - config = (builtins.readFile ./files/cmp.lua); - } - cmp-buffer - cmp-nvim-lsp - cmp-path - cmp-cmdline - cmp_luasnip - { - plugin = gitsigns-nvim; - type = "lua"; - config = (builtins.readFile ./files/luasnip.lua); - } - { - plugin = indent-blankline-nvim; - type = "lua"; - config ='' - require("ibl").setup{ - indent = { char = "│"}, - } - ''; - } - { - plugin = nvim-lspconfig; - type = "lua"; - config = (builtins.readFile ./files/lspconfig.lua); - } - { - plugin = lualine-nvim; - type = "lua"; - config = (builtins.readFile ./files/lualine.lua); - } - luasnip - { - plugin = neo-tree-nvim; - type = "lua"; - config = (builtins.readFile ./files/neotree.lua); - } - nui-nvim - plenary-nvim - { - plugin = (nvim-treesitter.withPlugins (p: [ - p.bash - p.c - p.cpp - p.cmake - p.dockerfile - p.latex - p.lua - p.llvm - p.markdown - p.markdown_inline - p.python - p.vim - p.yaml - ]) - ); - type = "lua"; - config = ( builtins.readFile ./files/treesitter.lua); - } - { - plugin = which-key-nvim; - type = "lua"; - config = ( builtins.readFile ./files/whichkey.lua ); - } - ]; - }; -} diff --git a/hosts/luci/home-config.nix b/hosts/luci/home-config.nix index 169bcf1..9c26a36 100644 --- a/hosts/luci/home-config.nix +++ b/hosts/luci/home-config.nix @@ -1,5 +1,6 @@ { ... }: { config.modules = { + cli.neovim.enable = true; video.kdenlive.enable = false; web.firefox.enable = true; web.qutebrowser.enable = true; diff --git a/modules/home-manager/cli/neovim/default.nix b/modules/home-manager/cli/neovim/default.nix new file mode 100644 index 0000000..341cda8 --- /dev/null +++ b/modules/home-manager/cli/neovim/default.nix @@ -0,0 +1,128 @@ +{ lib, pkgs, config, ... }: +with lib; +let + cfg = config.modules.cli.neovim; + nvim-spell-fr-utf8-dictionary = builtins.fetchurl { + url = "http://ftp.vim.org/vim/runtime/spell/fr.utf-8.spl"; + sha256 = "abfb9702b98d887c175ace58f1ab39733dc08d03b674d914f56344ef86e63b61"; + }; + nvim-spell-fr-utf8-suggestions = builtins.fetchurl { + url = "http://ftp.vim.org/vim/runtime/spell/fr.utf-8.sug"; + sha256 = "0294bc32b42c90bbb286a89e23ca3773b7ef50eff1ab523b1513d6a25c6b3f58"; + }; +in +{ + options.modules.cli.neovim = { + enable = mkEnableOption "enable Neovim text editor"; + }; + config = mkIf cfg.enable { + home.file."${config.xdg.configHome}/nvim/spell/fr.utf-8.spl".source = nvim-spell-fr-utf8-dictionary; + home.file."${config.xdg.configHome}/nvim/spell/fr.utf-8.sug".source = nvim-spell-fr-utf8-suggestions; + programs.neovim = { + enable = true; + defaultEditor = true; + vimAlias = true; + withNodeJs = true; + withPython3 = true; + extraPackages = with pkgs; [ + # LSP Servers + clang-tools + lua-language-server + marksman + nil + nodePackages.bash-language-server + python3Packages.python-lsp-server + rnix-lsp + shellcheck + + # Formatters + nixfmt + shfmt + ]; + extraLuaConfig = (builtins.readFile ./files/options.lua); + plugins = with pkgs.vimPlugins; [ + { + plugin = nvim-autopairs; + type = "lua"; + config = '' + local autopair = require("nvim-autopairs").setup {} + ''; + } + { + plugin = nvim-base16; + type = "lua"; + config = '' + vim.cmd.colorscheme 'base16-default-dark' + ''; + } + { + plugin = nvim-cmp; + type = "lua"; + config = (builtins.readFile ./files/cmp.lua); + } + cmp-buffer + cmp-nvim-lsp + cmp-path + cmp-cmdline + cmp_luasnip + { + plugin = gitsigns-nvim; + type = "lua"; + config = (builtins.readFile ./files/luasnip.lua); + } + { + plugin = indent-blankline-nvim; + type = "lua"; + config ='' + require("ibl").setup{ + indent = { char = "│"}, + } + ''; + } + { + plugin = nvim-lspconfig; + type = "lua"; + config = (builtins.readFile ./files/lspconfig.lua); + } + { + plugin = lualine-nvim; + type = "lua"; + config = (builtins.readFile ./files/lualine.lua); + } + luasnip + { + plugin = neo-tree-nvim; + type = "lua"; + config = (builtins.readFile ./files/neotree.lua); + } + nui-nvim + plenary-nvim + { + plugin = (nvim-treesitter.withPlugins (p: [ + p.bash + p.c + p.cpp + p.cmake + p.dockerfile + p.latex + p.lua + p.llvm + p.markdown + p.markdown_inline + p.python + p.vim + p.yaml + ]) + ); + type = "lua"; + config = ( builtins.readFile ./files/treesitter.lua); + } + { + plugin = which-key-nvim; + type = "lua"; + config = ( builtins.readFile ./files/whichkey.lua ); + } + ]; + }; + }; +} diff --git a/home-manager/cli/neovim/files/cmp.lua b/modules/home-manager/cli/neovim/files/cmp.lua similarity index 100% rename from home-manager/cli/neovim/files/cmp.lua rename to modules/home-manager/cli/neovim/files/cmp.lua diff --git a/home-manager/cli/neovim/files/lspconfig.lua b/modules/home-manager/cli/neovim/files/lspconfig.lua similarity index 100% rename from home-manager/cli/neovim/files/lspconfig.lua rename to modules/home-manager/cli/neovim/files/lspconfig.lua diff --git a/home-manager/cli/neovim/files/lualine.lua b/modules/home-manager/cli/neovim/files/lualine.lua similarity index 100% rename from home-manager/cli/neovim/files/lualine.lua rename to modules/home-manager/cli/neovim/files/lualine.lua diff --git a/home-manager/cli/neovim/files/luasnip.lua b/modules/home-manager/cli/neovim/files/luasnip.lua similarity index 100% rename from home-manager/cli/neovim/files/luasnip.lua rename to modules/home-manager/cli/neovim/files/luasnip.lua diff --git a/home-manager/cli/neovim/files/neotree.lua b/modules/home-manager/cli/neovim/files/neotree.lua similarity index 100% rename from home-manager/cli/neovim/files/neotree.lua rename to modules/home-manager/cli/neovim/files/neotree.lua diff --git a/home-manager/cli/neovim/files/options.lua b/modules/home-manager/cli/neovim/files/options.lua similarity index 100% rename from home-manager/cli/neovim/files/options.lua rename to modules/home-manager/cli/neovim/files/options.lua diff --git a/home-manager/cli/neovim/files/treesitter.lua b/modules/home-manager/cli/neovim/files/treesitter.lua similarity index 100% rename from home-manager/cli/neovim/files/treesitter.lua rename to modules/home-manager/cli/neovim/files/treesitter.lua diff --git a/home-manager/cli/neovim/files/whichkey.lua b/modules/home-manager/cli/neovim/files/whichkey.lua similarity index 100% rename from home-manager/cli/neovim/files/whichkey.lua rename to modules/home-manager/cli/neovim/files/whichkey.lua diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 750f0cf..0256121 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -1,6 +1,7 @@ { ... }: { imports = [ + ./cli/neovim ./desktop/sway ./gaming/lutris ./video/kdenlive