1

Update lazyvim module

This commit is contained in:
2024-06-03 20:36:27 +02:00
parent fc62ee87ae
commit 31e70b4973
3 changed files with 165 additions and 100 deletions

View File

@ -13,69 +13,138 @@ in {
options.modules.lazyvim = import ./options.nix {inherit lib mylib;};
config = mkIf cfg.enable {
# TODO: Configure by option
home.sessionVariables = {
EDITOR = "nvim";
VISUAL = "nvim";
};
home.packages = with pkgs; [
(pkgs.ripgrep.override {withPCRE2 = true;})
home.packages = with pkgs;
builtins.concatLists [
(optionals cfg.neovide [neovide])
# Linters
vale
[
(pkgs.ripgrep.override {withPCRE2 = true;})
# Formatters
alejandra # nix
jq # json
html-tidy # html
];
# Dependencies
lua51Packages.lua-curl # For rest
lua51Packages.xml2lua # For rest
lua51Packages.mimetypes # For rest
lua51Packages.jsregexp # For tree-sitter
# Language servers
clang-tools_18
clojure-lsp
cmake-language-server
haskell-language-server
lua-language-server
nil
pyright
rust-analyzer
texlab
# Linters
checkstyle # java
clippy # rust
clj-kondo # clojure
eslint_d # javascript
python311Packages.flake8
lua51Packages.luacheck
vale # text
statix # nix
# Formatters
alejandra # nix
python311Packages.black
google-java-format
html-tidy
jq # json
prettierd # html/css/js
rustfmt
stylua
]
];
home.file.".config/nvim/parser".source = let
parsers = pkgs.symlinkJoin {
name = "treesitter-parsers";
paths = pkgs.vimPlugins.nvim-treesitter.withAllGrammars.dependencies;
};
in "${parsers}/parser";
home.file.".config/neovide/config.toml".text = ''
fork = true # Start neovide detached
frame = "none" # full, buttonless, none
idle = true # Don't render frames without changes
# maximized = true
title-hidden = true
# vsync = true
'';
home.file.".config/vale/.vale.ini".text = ''
# Core settings appear at the top
# (the "global" section).
[formats]
# Format associations appear under
# the optional "formats" section.
[*]
# Format-specific settings appear
# under a user-provided "glob"
# pattern.
'';
programs.nixvim = {
enable = true;
defaultEditor = true;
enableMan = true;
colorschemes.catppuccin.enable = true;
luaLoader.enable = true;
# colorschemes.catppuccin.enable = true;
viAlias = cfg.alias;
vimAlias = cfg.alias;
opts = {
ruler = true; # Show cursor position in status line
number = true;
relativenumber = false;
showmode = false; # Status line already shows this
backspace = ["indent" "eol" "start"];
undofile = true;
undodir = "/home/christoph/.vim/undo"; # TODO: Use username variable
encoding = "utf-8";
# Search
incsearch = true; # Already highlight results while typing
hlsearch = true;
ignorecase = true;
laststatus = 2;
hidden = true; # Don't unload buffers immediately
# Indentation
autoindent = true;
expandtab = true;
smartindent = true;
smarttab = true;
shiftwidth = 4;
softtabstop = 4;
termguicolors = true; # For bufferline
globals = {
mapleader = " ";
mallocalleader = " ";
};
opts = import ./vim_opts.nix {inherit lib mylib;};
extraConfigLuaPost = builtins.readFile ./extraConfigLuaPost.lua;
# extraLuaPackages = with pkgs.lua51Packages; [];
# extraPython3Packages = p: [
# # For CHADtree
# p.pyyaml
# p.pynvim-pp
# p.std2
# ];
extraPlugins = with pkgs.vimPlugins; [
lazy-nvim
vim-airline-themes
nvim-web-devicons
# nvim-nio # For rest
];
autoCmd = [
{
event = ["BufWritePost"];
# pattern = "*";
callback = {__raw = "function() require('lint').try_lint() end";};
}
{
event = ["BufWritePre"];
callback = {__raw = "function() require('conform').format() end";};
}
];
# TODO: Toggle wrapping
# TODO: Toggle format on save
# TODO: Toggle format on paste
keymaps = import ./keybinds.nix {inherit lib mylib;};
extraConfigLua = let
plugins = with pkgs.vimPlugins; [
# LazyVim
LazyVim
LazyVim # Sets many vim options
bufferline-nvim
cmp-buffer
cmp-nvim-lsp
@ -148,6 +217,7 @@ in {
path = mini-nvim;
}
];
mkEntryFromDrv = drv:
if lib.isDerivation drv
then {
@ -155,37 +225,14 @@ in {
path = drv;
}
else drv;
lazyPath = pkgs.linkFarm "lazy-plugins" (builtins.map mkEntryFromDrv plugins);
in ''
require("lazy").setup({
defaults = {
lazy = true,
},
dev = {
-- reuse files from pkgs.vimPlugins.*
path = "${lazyPath}",
patterns = { "." },
-- fallback to download
fallback = true,
},
spec = {
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- The following configs are needed for fixing lazyvim on nix
-- force enable telescope-fzf-native.nvim
{ "nvim-telescope/telescope-fzf-native.nvim", enabled = true },
-- disable mason.nvim, use config.extraPackages
{ "williamboman/mason-lspconfig.nvim", enabled = false },
{ "williamboman/mason.nvim", enabled = false },
-- uncomment to import/override with your plugins
-- { import = "plugins" },
-- put this line at the end of spec to clear ensure_installed
{ "nvim-treesitter/nvim-treesitter", opts = { ensure_installed = {} } },
},
})
'';
viAlias = cfg.alias;
vimAlias = cfg.alias;
lazyPath = pkgs.linkFarm "lazy-plugins" (builtins.map mkEntryFromDrv plugins);
in (
builtins.replaceStrings
["@lazyPath@"]
["${lazyPath}"]
(builtins.readFile ./extraConfigLua.lua)
);
};
};
}

View File

@ -1,31 +1,5 @@
-- Package manager setup
require("lazy").setup({
defaults = {
lazy = true,
},
dev = {
-- reuse files from pkgs.vimPlugins.*
path = "@lazyPath@", -- NOTE: Will be replaced by the nix path
patterns = { "." },
-- fallback to download
fallback = true,
},
spec = {
-- { "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- The following configs are needed for fixing lazyvim on nix
-- force enable telescope-fzf-native.nvim
{ "nvim-telescope/telescope-fzf-native.nvim", enabled = true },
-- disable mason.nvim, use config.extraPackages
{ "williamboman/mason-lspconfig.nvim", enabled = false },
{ "williamboman/mason.nvim", enabled = false },
-- uncomment to import/override with your plugins
-- { import = "plugins" },
-- put this line at the end of spec to clear ensure_installed
{ "nvim-treesitter/nvim-treesitter", opts = { ensure_installed = {} } },
},
})
-- Skip loading LazyVim options
package.loaded["lazyvim.config.options"] = true
-- Hide inline diagnostics and show border
vim.diagnostic.config({
@ -39,3 +13,46 @@ vim.api.nvim_set_keymap("c", "<Up>", 'v:lua.get_wildmenu_key("<left>", "<up>")',
function _G.get_wildmenu_key(key_wildmenu, key_regular)
return vim.fn.wildmenumode() ~= 0 and key_wildmenu or key_regular
end
-- Package manager setup
require("lazy").setup({
defaults = {
lazy = true,
},
dev = {
-- reuse files from pkgs.vimPlugins.*
path = "@lazyPath@", -- NOTE: Will be replaced by the nix path
patterns = { "." },
-- fallback to download
fallback = true,
},
spec = {
{
"LazyVim/LazyVim",
import = "lazyvim.plugins",
opts = {
defaults = {
autocmds = false, -- Skip loading LazyVim cmds
keymaps = false, -- Skip loading LazyVim keymaps
},
},
},
-- force enable telescope-fzf-native.nvim on nix
{ "nvim-telescope/telescope-fzf-native.nvim", enabled = true },
-- disable mason.nvim, use config.extraPackages on nix
{ "williamboman/mason-lspconfig.nvim", enabled = false },
{ "williamboman/mason.nvim", enabled = false },
-- uncomment to import/override with your plugins
-- { import = "plugins" },
-- put this line at the end of spec to clear ensure_installed on nix
{ "nvim-treesitter/nvim-treesitter", opts = { ensure_installed = {} } },
},
})

View File

@ -7,4 +7,5 @@ with lib;
with mylib.modules; {
enable = mkEnableOpt "LazyVim";
alias = mkBoolOpt false "Link nvim to vim/vi";
neovide = mkEnableOpt "NeoVide";
}